Commit c01d65bc authored by unknown's avatar unknown

Cleanups

BTREE, HASH and RTREE are not reserved symbols anymore


mysql-test/t/loaddata.test:
  Removed empty lines
mysys/my_malloc.c:
  Fixed old style variable name
mysys/my_realloc.c:
  Fixed old style variable name
sql/sql_yacc.yy:
  BTREE, HASH and RTREE are not reserved symbols anymore
sql/table.cc:
  Simple optimization
parent 513917a5
......@@ -15,7 +15,3 @@ truncate table t1;
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
SELECT * from t1;
drop table t1;
......@@ -24,26 +24,26 @@
/* My memory allocator */
gptr my_malloc(unsigned int Size, myf MyFlags)
gptr my_malloc(unsigned int size, myf my_flags)
{
gptr point;
DBUG_ENTER("my_malloc");
DBUG_PRINT("my",("Size: %u MyFlags: %d",Size, MyFlags));
DBUG_PRINT("my",("size: %u my_flags: %d",size, my_flags));
if (!Size)
Size=1; /* Safety */
if ((point = (char*)malloc(Size)) == NULL)
if (!size)
size=1; /* Safety */
if ((point = (char*)malloc(size)) == NULL)
{
my_errno=errno;
if (MyFlags & MY_FAE)
if (my_flags & MY_FAE)
error_handler_hook=fatal_error_handler_hook;
if (MyFlags & (MY_FAE+MY_WME))
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),Size);
if (MyFlags & MY_FAE)
if (my_flags & (MY_FAE+MY_WME))
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
if (my_flags & MY_FAE)
exit(1);
}
else if (MyFlags & MY_ZEROFILL)
bzero(point,Size);
else if (my_flags & MY_ZEROFILL)
bzero(point,size);
DBUG_PRINT("exit",("ptr: %lx",point));
DBUG_RETURN(point);
} /* my_malloc */
......@@ -64,29 +64,29 @@ void my_no_flags_free(gptr ptr)
/* malloc and copy */
gptr my_memdup(const byte *from, uint length, myf MyFlags)
gptr my_memdup(const byte *from, uint length, myf my_flags)
{
gptr ptr;
if ((ptr=my_malloc(length,MyFlags)) != 0)
if ((ptr=my_malloc(length,my_flags)) != 0)
memcpy((byte*) ptr, (byte*) from,(size_t) length);
return(ptr);
}
char *my_strdup(const char *from, myf MyFlags)
char *my_strdup(const char *from, myf my_flags)
{
gptr ptr;
uint length=(uint) strlen(from)+1;
if ((ptr=my_malloc(length,MyFlags)) != 0)
if ((ptr=my_malloc(length,my_flags)) != 0)
memcpy((byte*) ptr, (byte*) from,(size_t) length);
return((my_string) ptr);
}
char *my_strdup_with_length(const byte *from, uint length, myf MyFlags)
char *my_strdup_with_length(const byte *from, uint length, myf my_flags)
{
gptr ptr;
if ((ptr=my_malloc(length+1,MyFlags)) != 0)
if ((ptr=my_malloc(length+1,my_flags)) != 0)
{
memcpy((byte*) ptr, (byte*) from,(size_t) length);
((char*) ptr)[length]=0;
......
......@@ -23,40 +23,41 @@
/* My memory re allocator */
gptr my_realloc(gptr oldpoint, uint Size, myf MyFlags)
gptr my_realloc(gptr oldpoint, uint size, myf my_flags)
{
gptr point;
DBUG_ENTER("my_realloc");
DBUG_PRINT("my",("ptr: %lx Size: %u MyFlags: %d",oldpoint, Size, MyFlags));
DBUG_PRINT("my",("ptr: %lx size: %u my_flags: %d",oldpoint, size,
my_flags));
if (!oldpoint && (MyFlags & MY_ALLOW_ZERO_PTR))
DBUG_RETURN(my_malloc(Size,MyFlags));
if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
DBUG_RETURN(my_malloc(size,my_flags));
#ifdef USE_HALLOC
if (!(point = malloc(Size)))
if (!(point = malloc(size)))
{
if (MyFlags & MY_FREE_ON_ERROR)
my_free(oldpoint,MyFlags);
if (MyFlags & MY_HOLD_ON_ERROR)
if (my_flags & MY_FREE_ON_ERROR)
my_free(oldpoint,my_flags);
if (my_flags & MY_HOLD_ON_ERROR)
DBUG_RETURN(oldpoint);
my_errno=errno;
if (MyFlags & MY_FAE+MY_WME)
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),Size);
if (my_flags & MY_FAE+MY_WME)
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
}
else
{
memcpy(point,oldpoint,Size);
memcpy(point,oldpoint,size);
free(oldpoint);
}
#else
if ((point = (char*)realloc(oldpoint,Size)) == NULL)
if ((point = (char*)realloc(oldpoint,size)) == NULL)
{
if (MyFlags & MY_FREE_ON_ERROR)
if (my_flags & MY_FREE_ON_ERROR)
my_free(oldpoint,MyFLAGS);
if (MyFlags & MY_HOLD_ON_ERROR)
if (my_flags & MY_HOLD_ON_ERROR)
DBUG_RETURN(oldpoint);
my_errno=errno;
if (MyFlags & (MY_FAE+MY_WME))
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), Size);
if (my_flags & (MY_FAE+MY_WME))
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size);
}
#endif
DBUG_PRINT("exit",("ptr: %lx",point));
......
......@@ -4363,6 +4363,7 @@ keyword:
| BOOL_SYM {}
| BOOLEAN_SYM {}
| BYTE_SYM {}
| BTREE_SYM {}
| CACHE_SYM {}
| CHANGED {}
| CHARSET {}
......@@ -4408,6 +4409,7 @@ keyword:
| GRANTS {}
| GLOBAL_SYM {}
| HANDLER_SYM {}
| HASH_SYM {}
| HEAP_SYM {}
| HELP_SYM {}
| HOSTS_SYM {}
......@@ -4490,6 +4492,7 @@ keyword:
| ROWS_SYM {}
| ROW_FORMAT_SYM {}
| ROW_SYM {}
| RTREE_SYM {}
| SAVEPOINT_SYM {}
| SECOND_SYM {}
| SERIAL_SYM {}
......
......@@ -1207,17 +1207,14 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res)
char *get_field(MEM_ROOT *mem, Field *field)
{
char buff[MAX_FIELD_WIDTH], *to;
char buff[MAX_FIELD_WIDTH];
String str(buff,sizeof(buff),&my_charset_bin);
uint length;
field->val_str(&str,&str);
if (!(length= str.length()))
return NullS;
to= (char*) alloc_root(mem,length+1);
memcpy(to, str.ptr(), (uint) length);
to[length]=0;
return to;
return strmake_root(mem, str.ptr(), length);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment