maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #01168
A mess with sql_alloc() ?
I need to use sql_string.* and sql_list.* in MYSQL_CLIENT context (mysqlbinlog.cc).
sql_list.h refers to sql_alloc() function which originally has "THD dependent"
implementation:
mysql_priv.h:
#ifndef MYSQL_CLIENT
...
(1) void *sql_alloc(size_t);
...
#endif
thr_malloc.cc:
void *sql_alloc(size_t Size)
{
MEM_ROOT *root= *my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
return alloc_root(root,Size);
}
So I redefined sql_alloc() in a client context:
void *sql_alloc(size_t size) { ... }
...
#include "sql_string.h"
#include "sql_list.h"
And this appeared to run into conflict with
sql/sql_string.cc:
(2) extern uchar* sql_alloc(unsigned size);
Moreover I found the following declaration
client\sql_string.cc:
(3) extern void sql_alloc(size_t size);
Isn't it a mess: compare (1), (2) and (3) ?
Actually, looks like both (2) & (3) are reducible:
- I found no direct usage of sql_alloc() in sql_string.* files;
- After commenting (2) & (3) out the rebuild was successfull.
If (2) & (3) shouldn't be deleted, then they should be brought
in correspondence with (1). If not, what should I do to redefine
sql_alloc()?
Looks like along with sql_alloc(), we can delete similar declarations
(2a) & (3a) of sql_element_free() (and actually all occurences of this function):
mysql_priv.h
#ifndef MYSQL_CLIENT
...
(1a) void sql_element_free(void *ptr);
...
#endif
thr_malloc.cc
void sql_element_free(void *ptr __attribute__((unused)))
{} /* purecov: deadcode */
sql/sql_string.cc
(2a) extern void sql_element_free(void *ptr);
client/sql_string.cc
(3a) extern void sql_element_free(void *ptr);
Indeed, besides pointed above we find only the following
occurences of sql_element_free():
client/mysql.cc
void* sql_alloc(unsigned size);
void sql_element_free(void *ptr);
...
void *sql_alloc(size_t Size)
{
return my_malloc(Size,MYF(MY_WME));
}
void sql_element_free(void *ptr)
{
my_free(ptr,MYF(0));
}
So sql_element_free() is called nowhere (note also that this function
has a do-nothing body).
Follow ups