summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2010-07-08 18:20:08 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2010-07-08 18:20:08 -0300
commitf56dd32bf7c5b8a8cf35984f39f1a253b75945ff (patch)
tree6c88c3c07b30acb464ca8bf81bbef916216da616 /client
parentd3b01fef18b20f3ac589f2ecc95d64326570583f (diff)
downloadmariadb-git-f56dd32bf7c5b8a8cf35984f39f1a253b75945ff.tar.gz
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly slow as it checks all allocated blocks for overrun at each memory management primitive, yielding a almost exponential slowdown for the memory management functions (malloc, realloc, free). The overrun check basically consists of verifying some bytes of a block for certain magic keys, which catches some simple forms of overrun. Another minor problem is violation of aliasing rules and that its own internal list of blocks is prone to corruption. Another issue with safemalloc is rather the maintenance cost as the tool has a significant impact on the server code. Given the magnitude of memory debuggers available nowadays, especially those that are provided with the platform malloc implementation, maintenance of a in-house and largely obsolete memory debugger becomes a burden that is not worth the effort due to its slowness and lack of support for detecting more common forms of heap corruption. Since there are third-party tools that can provide the same functionality at a lower or comparable performance cost, the solution is to simply remove safemalloc. Third-party tools can provide the same functionality at a lower or comparable performance cost. The removal of safemalloc also allows a simplification of the malloc wrappers, removing quite a bit of kludge: redefinition of my_malloc, my_free and the removal of the unused second argument of my_free. Since free() always check whether the supplied pointer is null, redudant checks are also removed. Also, this patch adds unit testing for my_malloc and moves my_realloc implementation into the same file as the other memory allocation primitives. client/mysqldump.c: Pass my_free directly as its signature is compatible with the callback type -- which wasn't the case for free_table_ent.
Diffstat (limited to 'client')
-rw-r--r--client/completion_hash.cc3
-rw-r--r--client/mysql.cc48
-rw-r--r--client/mysqladmin.cc12
-rw-r--r--client/mysqlbinlog.cc34
-rw-r--r--client/mysqlcheck.c12
-rw-r--r--client/mysqldump.c29
-rw-r--r--client/mysqlimport.c6
-rw-r--r--client/mysqlshow.c7
-rw-r--r--client/mysqlslap.c38
-rw-r--r--client/mysqltest.cc102
-rw-r--r--client/readline.cc8
-rw-r--r--client/sql_string.h2
12 files changed, 138 insertions, 163 deletions
diff --git a/client/completion_hash.cc b/client/completion_hash.cc
index cd0ea17dfaf..dc7f0329db8 100644
--- a/client/completion_hash.cc
+++ b/client/completion_hash.cc
@@ -22,7 +22,6 @@
#include <my_global.h>
#include <m_string.h>
-#undef SAFEMALLOC // Speed things up
#include <my_sys.h>
#include "completion_hash.h"
@@ -213,7 +212,7 @@ void completion_hash_clean(HashTable *ht)
void completion_hash_free(HashTable *ht)
{
completion_hash_clean(ht);
- my_free(ht->arBuckets, MYF(0));
+ my_free(ht->arBuckets);
}
diff --git a/client/mysql.cc b/client/mysql.cc
index 58ef51f3fff..d64bd8f686a 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1205,7 +1205,7 @@ int main(int argc,char *argv[])
strncmp(link_name, "/dev/null", 10) == 0)
{
/* The .mysql_history file is a symlink to /dev/null, don't use it */
- my_free(histfile, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(histfile);
histfile= 0;
}
}
@@ -1266,23 +1266,23 @@ sig_handler mysql_end(int sig)
glob_buffer.free();
old_buffer.free();
processed_prompt.free();
- my_free(server_version,MYF(MY_ALLOW_ZERO_PTR));
- my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
- my_free(opt_mysql_unix_port,MYF(MY_ALLOW_ZERO_PTR));
- my_free(histfile,MYF(MY_ALLOW_ZERO_PTR));
- my_free(histfile_tmp,MYF(MY_ALLOW_ZERO_PTR));
- my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
- my_free(current_host,MYF(MY_ALLOW_ZERO_PTR));
- my_free(current_user,MYF(MY_ALLOW_ZERO_PTR));
- my_free(full_username,MYF(MY_ALLOW_ZERO_PTR));
- my_free(part_username,MYF(MY_ALLOW_ZERO_PTR));
- my_free(default_prompt,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(server_version);
+ my_free(opt_password);
+ my_free(opt_mysql_unix_port);
+ my_free(histfile);
+ my_free(histfile_tmp);
+ my_free(current_db);
+ my_free(current_host);
+ my_free(current_user);
+ my_free(full_username);
+ my_free(part_username);
+ my_free(default_prompt);
#ifdef HAVE_SMEM
- my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(shared_memory_base_name);
#endif
- my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(current_prompt);
while (embedded_server_arg_count > 1)
- my_free(embedded_server_args[--embedded_server_arg_count],MYF(0));
+ my_free(embedded_server_args[--embedded_server_arg_count]);
mysql_server_end();
free_defaults(defaults_argv);
my_end(my_end_arg);
@@ -1736,7 +1736,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (argument)
{
char *start= argument;
- my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
opt_password= my_strdup(argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; // Destroy argument
if (*start)
@@ -1833,7 +1833,7 @@ static int get_options(int argc, char **argv)
if (argc == 1)
{
skip_updates= 0;
- my_free(current_db, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(current_db);
current_db= my_strdup(*argv, MYF(MY_WME));
}
if (tty_password)
@@ -2731,7 +2731,7 @@ static void get_current_db()
{
MYSQL_RES *res;
- my_free(current_db, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(current_db);
current_db= NULL;
/* In case of error below current_db will be NULL */
if (!mysql_query(&mysql, "SELECT DATABASE()") &&
@@ -4023,12 +4023,12 @@ com_connect(String *buffer, char *line)
tmp= get_arg(buff, 0);
if (tmp && *tmp)
{
- my_free(current_db, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(current_db);
current_db= my_strdup(tmp, MYF(MY_WME));
tmp= get_arg(buff, 1);
if (tmp)
{
- my_free(current_host,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(current_host);
current_host=my_strdup(tmp,MYF(MY_WME));
}
}
@@ -4200,7 +4200,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
if (mysql_select_db(&mysql,tmp))
return put_error(&mysql);
}
- my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(current_db);
current_db=my_strdup(tmp,MYF(MY_WME));
#ifdef HAVE_READLINE
if (select_db > 1)
@@ -4952,8 +4952,8 @@ static void add_int_to_prompt(int toadd)
static void init_username()
{
- my_free(full_username,MYF(MY_ALLOW_ZERO_PTR));
- my_free(part_username,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(full_username);
+ my_free(part_username);
MYSQL_RES *result;
LINT_INIT(result);
@@ -4971,7 +4971,7 @@ static int com_prompt(String *buffer, char *line)
{
char *ptr=strchr(line, ' ');
prompt_counter = 0;
- my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(current_prompt);
current_prompt=my_strdup(ptr ? ptr+1 : default_prompt,MYF(MY_WME));
if (!ptr)
tee_fprintf(stdout, "Returning to default PROMPT of %s\n", default_prompt);
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 64371224e2b..bf0dec01d2f 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -236,7 +236,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (argument)
{
char *start=argument;
- my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
opt_password=my_strdup(argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
@@ -448,10 +448,10 @@ int main(int argc,char *argv[])
} /* got connection */
mysql_close(&mysql);
- my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
- my_free(user,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
+ my_free(user);
#ifdef HAVE_SMEM
- my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(shared_memory_base_name);
#endif
free_defaults(save_argv);
my_end(my_end_arg);
@@ -1008,8 +1008,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
/* free up memory from prompted password */
if (typed_password != argv[1])
{
- my_free(typed_password,MYF(MY_ALLOW_ZERO_PTR));
- my_free(verified,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(typed_password);
+ my_free(verified);
}
argc--; argv++;
break;
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 9d85e24d03f..d8b57381904 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -68,20 +68,20 @@ TYPELIB base64_output_mode_typelib=
{ array_elements(base64_output_mode_names) - 1, "",
base64_output_mode_names, NULL };
static enum_base64_output_mode opt_base64_output_mode= BASE64_OUTPUT_UNSPEC;
-static const char *opt_base64_output_mode_str= NullS;
-static const char* database= 0;
+static char *opt_base64_output_mode_str= NullS;
+static char* database= 0;
static my_bool force_opt= 0, short_form= 0, remote_opt= 0;
static my_bool debug_info_flag, debug_check_flag;
static my_bool force_if_open_opt= 1;
static ulonglong offset = 0;
-static const char* host = 0;
+static char* host = 0;
static int port= 0;
static uint my_end_arg;
static const char* sock= 0;
#ifdef HAVE_SMEM
static char *shared_memory_base_name= 0;
#endif
-static const char* user = 0;
+static char* user = 0;
static char* pass = 0;
static char *charset= 0;
@@ -96,7 +96,7 @@ static my_time_t start_datetime= 0, stop_datetime= MY_TIME_T_MAX;
static ulonglong rec_count= 0;
static short binlog_flags = 0;
static MYSQL* mysql = NULL;
-static const char* dirname_for_local_load= 0;
+static char* dirname_for_local_load= 0;
/**
Pointer to the Format_description_log_event of the currently active binlog.
@@ -191,7 +191,7 @@ public:
int init()
{
return init_dynamic_array(&file_names, sizeof(File_name_record),
- 100,100 CALLER_INFO);
+ 100, 100);
}
void init_by_dir_name(const char *dir)
@@ -213,7 +213,7 @@ public:
{
if (ptr->fname)
{
- my_free(ptr->fname, MYF(MY_WME));
+ my_free(ptr->fname);
delete ptr->event;
bzero((char *)ptr, sizeof(File_name_record));
}
@@ -442,7 +442,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
{
error("Could not construct local filename %s%s.",
target_dir_name,bname);
- my_free(fname, MYF(0));
+ my_free(fname);
delete ce;
DBUG_RETURN(ERROR_STOP);
}
@@ -458,7 +458,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
if (set_dynamic(&file_names, (uchar*)&rec, file_id))
{
error("Out of memory.");
- my_free(fname, MYF(0));
+ my_free(fname);
delete ce;
DBUG_RETURN(ERROR_STOP);
}
@@ -822,7 +822,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
*/
convert_path_to_forward_slashes((char*) ce->fname);
ce->print(result_file, print_event_info, TRUE);
- my_free((char*)ce->fname,MYF(MY_WME));
+ my_free((void*)ce->fname);
delete ce;
}
else
@@ -887,7 +887,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
}
if (fname)
- my_free(fname, MYF(MY_WME));
+ my_free(fname);
break;
}
case TABLE_MAP_EVENT:
@@ -1222,11 +1222,11 @@ static void warning(const char *format,...)
*/
static void cleanup()
{
- my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*) database, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*) host, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*) user, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*) dirname_for_local_load, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(pass);
+ my_free(database);
+ my_free(host);
+ my_free(user);
+ my_free(dirname_for_local_load);
delete glob_description_event;
if (mysql)
@@ -1306,7 +1306,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
argument= (char*) ""; // Don't require password
if (argument)
{
- my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(pass);
char *start=argument;
pass= my_strdup(argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 1fc9f179895..2c9c563e17f 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -291,7 +291,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (argument)
{
char *start = argument;
- my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
opt_password = my_strdup(argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
@@ -470,7 +470,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
}
*--end = 0;
handle_request_for_tables(table_names_comma_sep + 1, (uint) (tot_length - 1));
- my_free(table_names_comma_sep, MYF(0));
+ my_free(table_names_comma_sep);
}
else
for (; tables > 0; tables--, table_names++)
@@ -569,7 +569,7 @@ static int process_all_tables_in_db(char *database)
*--end = 0;
if (tot_length)
handle_request_for_tables(tables + 1, tot_length - 1);
- my_free(tables, MYF(0));
+ my_free(tables);
}
else
{
@@ -727,7 +727,7 @@ static int handle_request_for_tables(char *tables, uint length)
return 1;
}
print_result();
- my_free(query, MYF(0));
+ my_free(query);
return 0;
}
@@ -899,9 +899,9 @@ int main(int argc, char **argv)
dbDisconnect(current_host);
if (opt_auto_repair)
delete_dynamic(&tables4repair);
- my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
#ifdef HAVE_SMEM
- my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(shared_memory_base_name);
#endif
my_end(my_end_arg);
return(first_error!=0);
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 2d92f0891eb..6d294153c54 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -715,12 +715,6 @@ static void write_footer(FILE *sql_file)
} /* write_footer */
-static void free_table_ent(char *key)
-{
- my_free(key, MYF(0));
-}
-
-
uchar* get_table_key(const char *entry, size_t *length,
my_bool not_used __attribute__((unused)))
{
@@ -745,7 +739,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (argument)
{
char *start=argument;
- my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
opt_password=my_strdup(argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
@@ -905,8 +899,7 @@ static int get_options(int *argc, char ***argv)
defaults_argv= *argv;
if (my_hash_init(&ignore_table, charset_info, 16, 0, 0,
- (my_hash_get_key) get_table_key,
- (my_hash_free_key) free_table_ent, 0))
+ (my_hash_get_key) get_table_key, my_free, 0))
return(EX_EOM);
/* Don't copy internal log tables */
if (my_hash_insert(&ignore_table,
@@ -1420,7 +1413,7 @@ static void free_resources()
{
if (md_result_file && md_result_file != stdout)
my_fclose(md_result_file, MYF(0));
- my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
if (my_hash_inited(&ignore_table))
my_hash_free(&ignore_table);
if (extended_insert)
@@ -1534,7 +1527,7 @@ static void unescape(FILE *file,char *pos,uint length)
fputs(tmp, file);
fputc('\'', file);
check_io(file);
- my_free(tmp, MYF(MY_WME));
+ my_free(tmp);
DBUG_VOID_RETURN;
} /* unescape */
@@ -2201,7 +2194,7 @@ static uint dump_routines_for_db(char *db)
}
}
- my_free(query_str, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(query_str);
}
} /* end of routine printing */
mysql_free_result(routine_res);
@@ -2374,12 +2367,12 @@ static uint get_table_structure(char *table, char *db, char *table_type,
if (mysql_errno(mysql) == ER_VIEW_INVALID)
fprintf(sql_file, "\n-- failed on view %s: %s\n\n", result_table, scv_buff ? scv_buff : "");
- my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(scv_buff);
DBUG_RETURN(0);
}
else
- my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(scv_buff);
if (mysql_num_rows(result))
{
@@ -2855,7 +2848,7 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
DBUG_RETURN(TRUE);
}
- my_free(query_str, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(query_str);
}
DBUG_RETURN(FALSE);
@@ -4073,7 +4066,7 @@ static int dump_all_tables_in_db(char *database)
if (include_table((uchar*) hash_key, end - hash_key))
{
dump_table(table,database);
- my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(order_by);
order_by= 0;
if (opt_dump_triggers && ! opt_xml &&
mysql_get_server_version(mysql) >= 50009)
@@ -4345,7 +4338,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
dump_routines_for_db(db);
}
free_root(&root, MYF(0));
- my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(order_by);
order_by= 0;
if (opt_xml)
{
@@ -5258,7 +5251,7 @@ int main(int argc, char **argv)
goto err;
#ifdef HAVE_SMEM
- my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(shared_memory_base_name);
#endif
/*
No reason to explicitely COMMIT the transaction, neither to explicitely
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 3bf17cb1df7..fdb521b9cf8 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -230,7 +230,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (argument)
{
char *start=argument;
- my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
opt_password=my_strdup(argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
@@ -684,9 +684,9 @@ int main(int argc, char **argv)
exitcode= error;
db_disconnect(current_host, mysql);
}
- my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
#ifdef HAVE_SMEM
- my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(shared_memory_base_name);
#endif
free_defaults(argv_to_free);
my_end(my_end_arg);
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index d8561d13b81..76f9048e09e 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -149,10 +149,9 @@ int main(int argc, char **argv)
break;
}
mysql_close(&mysql); /* Close & free connection */
- if (opt_password)
- my_free(opt_password,MYF(0));
+ my_free(opt_password);
#ifdef HAVE_SMEM
- my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(shared_memory_base_name);
#endif
my_end(my_end_arg);
exit(error ? 1 : 0);
@@ -292,7 +291,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (argument)
{
char *start=argument;
- my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
opt_password=my_strdup(argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 714a8cb9039..e411b096d68 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -399,10 +399,8 @@ int main(int argc, char **argv)
mysql_close(&mysql); /* Close & free connection */
/* now free all the strings we created */
- if (opt_password)
- my_free(opt_password, MYF(0));
-
- my_free(concurrency, MYF(0));
+ my_free(opt_password);
+ my_free(concurrency);
statement_cleanup(create_statements);
statement_cleanup(query_statements);
@@ -411,8 +409,7 @@ int main(int argc, char **argv)
option_cleanup(engine_options);
#ifdef HAVE_SMEM
- if (shared_memory_base_name)
- my_free(shared_memory_base_name, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(shared_memory_base_name);
#endif
free_defaults(defaults_argv);
my_end(my_end_arg);
@@ -504,7 +501,7 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
if (opt_csv_str)
print_conclusions_csv(&conclusion);
- my_free(head_sptr, MYF(0));
+ my_free(head_sptr);
}
@@ -721,7 +718,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (argument)
{
char *start= argument;
- my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_password);
opt_password= my_strdup(argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
@@ -1367,7 +1364,7 @@ get_options(int *argc,char ***argv)
tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0));
parse_delimiter(tmp_string, &create_statements, delimiter[0]);
- my_free(tmp_string, MYF(0));
+ my_free(tmp_string);
}
else if (create_string)
{
@@ -1396,7 +1393,7 @@ get_options(int *argc,char ***argv)
if (user_supplied_query)
actual_queries= parse_delimiter(tmp_string, &query_statements,
delimiter[0]);
- my_free(tmp_string, MYF(0));
+ my_free(tmp_string);
}
else if (user_supplied_query)
{
@@ -1427,7 +1424,7 @@ get_options(int *argc,char ***argv)
if (user_supplied_pre_statements)
(void)parse_delimiter(tmp_string, &pre_statements,
delimiter[0]);
- my_free(tmp_string, MYF(0));
+ my_free(tmp_string);
}
else if (user_supplied_pre_statements)
{
@@ -1458,7 +1455,7 @@ get_options(int *argc,char ***argv)
if (user_supplied_post_statements)
(void)parse_delimiter(tmp_string, &post_statements,
delimiter[0]);
- my_free(tmp_string, MYF(0));
+ my_free(tmp_string);
}
else if (user_supplied_post_statements)
{
@@ -1555,9 +1552,9 @@ drop_primary_key_list(void)
if (primary_keys_number_of)
{
for (counter= 0; counter < primary_keys_number_of; counter++)
- my_free(primary_keys[counter], MYF(0));
+ my_free(primary_keys[counter]);
- my_free(primary_keys, MYF(0));
+ my_free(primary_keys);
}
return 0;
@@ -2154,11 +2151,9 @@ option_cleanup(option_string *stmt)
for (ptr= stmt; ptr; ptr= nptr)
{
nptr= ptr->next;
- if (ptr->string)
- my_free(ptr->string, MYF(0));
- if (ptr->option)
- my_free(ptr->option, MYF(0));
- my_free(ptr, MYF(0));
+ my_free(ptr->string);
+ my_free(ptr->option);
+ my_free(ptr);
}
}
@@ -2172,9 +2167,8 @@ statement_cleanup(statement *stmt)
for (ptr= stmt; ptr; ptr= nptr)
{
nptr= ptr->next;
- if (ptr->string)
- my_free(ptr->string, MYF(0));
- my_free(ptr, MYF(0));
+ my_free(ptr->string);
+ my_free(ptr);
}
}
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 75b23ea9af7..1d821c18111 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -84,10 +84,10 @@ static my_bool get_one_option(int optid, const struct my_option *,
C_MODE_END
enum {
- OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
- OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
- OPT_MAX_CONNECT_RETRIES, OPT_MAX_CONNECTIONS, OPT_MARK_PROGRESS,
- OPT_LOG_DIR, OPT_TAIL_LINES, OPT_RESULT_FORMAT_VERSION
+ OPT_PS_PROTOCOL=OPT_MAX_CLIENT_OPTION, OPT_SP_PROTOCOL,
+ OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, OPT_MAX_CONNECT_RETRIES,
+ OPT_MAX_CONNECTIONS, OPT_MARK_PROGRESS, OPT_LOG_DIR,
+ OPT_TAIL_LINES, OPT_RESULT_FORMAT_VERSION
};
static int record= 0, opt_sleep= -1;
@@ -156,7 +156,7 @@ static struct st_block *cur_block, *block_stack_end;
struct st_test_file
{
FILE* file;
- const char *file_name;
+ char *file_name;
uint lineno; /* Current line in file */
};
@@ -1106,9 +1106,9 @@ void close_connections()
mysql_close(&next_con->mysql);
if (next_con->util_mysql)
mysql_close(next_con->util_mysql);
- my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(next_con->name);
}
- my_free(connections, MYF(MY_WME));
+ my_free(connections);
DBUG_VOID_RETURN;
}
@@ -1137,7 +1137,7 @@ void close_files()
DBUG_PRINT("info", ("closing file: %s", cur_file->file_name));
fclose(cur_file->file);
}
- my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(cur_file->file_name);
cur_file->file_name= 0;
}
DBUG_VOID_RETURN;
@@ -1157,22 +1157,22 @@ void free_used_memory()
for (i= 0 ; i < q_lines.elements ; i++)
{
struct st_command **q= dynamic_element(&q_lines, i, struct st_command**);
- my_free((*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR));
+ my_free((*q)->query_buf);
if ((*q)->content.str)
dynstr_free(&(*q)->content);
- my_free((*q),MYF(0));
+ my_free((*q));
}
for (i= 0; i < 10; i++)
{
if (var_reg[i].alloced_len)
- my_free(var_reg[i].str_val, MYF(MY_WME));
+ my_free(var_reg[i].str_val);
}
while (embedded_server_arg_count > 1)
- my_free(embedded_server_args[--embedded_server_arg_count],MYF(0));
+ my_free(embedded_server_args[--embedded_server_arg_count]);
delete_dynamic(&q_lines);
dynstr_free(&ds_res);
free_all_replace();
- my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_pass);
free_defaults(default_argv);
free_re();
#ifdef __WIN__
@@ -1933,9 +1933,10 @@ static uchar *get_var_key(const uchar* var, size_t *len,
static void var_free(void *v)
{
- my_free(((VAR*) v)->str_val, MYF(MY_WME));
- if (((VAR*)v)->alloced)
- my_free(v, MYF(MY_WME));
+ VAR *var= (VAR*) v;
+ my_free(var->str_val);
+ if (var->alloced)
+ my_free(var);
}
C_MODE_END
@@ -4824,7 +4825,7 @@ void do_close_connection(struct st_command *command)
con->util_mysql= 0;
con->pending= FALSE;
- my_free(con->name, MYF(0));
+ my_free(con->name);
/*
When the connection is closed set name to "-closed_connection-"
@@ -5491,7 +5492,7 @@ int read_line(char *buf, int size)
fclose(cur_file->file);
cur_file->file= 0;
}
- my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(cur_file->file_name);
cur_file->file_name= 0;
if (cur_file == file_stack)
{
@@ -5967,9 +5968,6 @@ static struct my_option my_long_options[] =
0, 0, 0},
{"silent", 's', "Suppress all normal output. Synonym for --quiet.",
&silent, &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"skip-safemalloc", OPT_SKIP_SAFEMALLOC,
- "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG,
- 0, 0, 0, 0, 0, 0},
{"sleep", 'T', "Always sleep this many seconds on sleep commands.",
&opt_sleep, &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, -1, 0,
0, 0, 0},
@@ -6125,7 +6123,7 @@ get_one_option(int optid, const struct my_option *, char *argument)
argument= (char*) ""; // Don't require password
if (argument)
{
- my_free(opt_pass, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_pass);
opt_pass= my_strdup(argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
tty_password= 0;
@@ -6158,11 +6156,6 @@ get_one_option(int optid, const struct my_option *, char *argument)
case 'F':
read_embedded_server_arguments(argument);
break;
- case OPT_SKIP_SAFEMALLOC:
-#ifdef SAFEMALLOC
- sf_malloc_quick=1;
-#endif
- break;
case OPT_RESULT_FORMAT_VERSION:
set_result_format_version(opt_result_format_version);
break;
@@ -6321,7 +6314,7 @@ void init_win_path_patterns()
/* Don't insert zero length strings in patterns array */
if (strlen(p) == 0)
{
- my_free(p, MYF(0));
+ my_free(p);
continue;
}
@@ -6345,7 +6338,7 @@ void free_win_path_patterns()
for (i=0 ; i < patterns.elements ; i++)
{
const char** pattern= dynamic_element(&patterns, i, const char**);
- my_free((char*) *pattern, MYF(0));
+ my_free(*pattern);
}
delete_dynamic(&patterns);
}
@@ -6538,12 +6531,12 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
for (i= 0; i < num_fields; i++)
{
/* Free data for output */
- my_free(my_bind[i].buffer, MYF(MY_WME | MY_FAE));
+ my_free(my_bind[i].buffer);
}
/* Free array with bind structs, lengths and NULL flags */
- my_free(my_bind , MYF(MY_WME | MY_FAE));
- my_free(length , MYF(MY_WME | MY_FAE));
- my_free(is_null , MYF(MY_WME | MY_FAE));
+ my_free(my_bind);
+ my_free(length);
+ my_free(is_null);
}
@@ -8489,11 +8482,11 @@ void do_get_replace_column(struct st_command *command)
if (!*from)
die("Wrong number of arguments to replace_column in '%s'", command->query);
to= get_string(&buff, &from, command);
- my_free(replace_column[column_number-1], MY_ALLOW_ZERO_PTR);
+ my_free(replace_column[column_number-1]);
replace_column[column_number-1]= my_strdup(to, MYF(MY_WME | MY_FAE));
set_if_bigger(max_replace_column, column_number);
}
- my_free(start, MYF(0));
+ my_free(start);
command->last_argument= command->end;
DBUG_VOID_RETURN;
@@ -8507,7 +8500,7 @@ void free_replace_column()
{
if (replace_column[i])
{
- my_free(replace_column[i], 0);
+ my_free(replace_column[i]);
replace_column[i]= 0;
}
}
@@ -8588,7 +8581,7 @@ void do_get_replace(struct st_command *command)
die("Can't initialize replace from '%s'", command->query);
free_pointer_array(&from_array);
free_pointer_array(&to_array);
- my_free(start, MYF(0));
+ my_free(start);
command->last_argument= command->end;
DBUG_VOID_RETURN;
}
@@ -8597,11 +8590,8 @@ void do_get_replace(struct st_command *command)
void free_replace()
{
DBUG_ENTER("free_replace");
- if (glob_replace)
- {
- my_free(glob_replace,MYF(0));
- glob_replace=0;
- }
+ my_free(glob_replace);
+ glob_replace= NULL;
DBUG_VOID_RETURN;
}
@@ -8821,7 +8811,7 @@ struct st_replace_regex* init_replace_regex(char* expr)
return res;
err:
- my_free(res,0);
+ my_free(res);
die("Error parsing replace_regex \"%s\"", expr);
return 0;
}
@@ -8913,9 +8903,9 @@ void free_replace_regex()
if (glob_replace_regex)
{
delete_dynamic(&glob_replace_regex->regex_arr);
- my_free(glob_replace_regex->even_buf,MYF(MY_ALLOW_ZERO_PTR));
- my_free(glob_replace_regex->odd_buf,MYF(MY_ALLOW_ZERO_PTR));
- my_free(glob_replace_regex,MYF(0));
+ my_free(glob_replace_regex->even_buf);
+ my_free(glob_replace_regex->odd_buf);
+ my_free(glob_replace_regex);
glob_replace_regex=0;
}
}
@@ -9110,7 +9100,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
str_p= str_end;
}
}
- my_free(subs, MYF(0));
+ my_free(subs);
my_regfree(&r);
*res_p= 0;
*buf_p= buf;
@@ -9242,7 +9232,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME))))
{
free_sets(&sets);
- my_free(found_set,MYF(0));
+ my_free(found_set);
DBUG_RETURN(0);
}
@@ -9437,9 +9427,9 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1));
}
}
- my_free(follow,MYF(0));
+ my_free(follow);
free_sets(&sets);
- my_free(found_set,MYF(0));
+ my_free(found_set);
DBUG_PRINT("exit",("Replace table has %d states",sets.count));
DBUG_RETURN(replace);
}
@@ -9455,7 +9445,7 @@ int init_sets(REP_SETS *sets,uint states)
if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits*
SET_MALLOC_HUNC,MYF(MY_WME))))
{
- my_free(sets->set,MYF(0));
+ my_free(sets->set);
return 1;
}
return 0;
@@ -9516,8 +9506,8 @@ void free_last_set(REP_SETS *sets)
void free_sets(REP_SETS *sets)
{
- my_free(sets->set_buffer,MYF(0));
- my_free(sets->bit_buffer,MYF(0));
+ my_free(sets->set_buffer);
+ my_free(sets->bit_buffer);
return;
}
@@ -9657,7 +9647,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
MYF(MY_WME))))
{
- my_free((char*) pa->typelib.type_names,MYF(0));
+ my_free(pa->typelib.type_names);
DBUG_RETURN (-1);
}
pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
@@ -9718,9 +9708,9 @@ void free_pointer_array(POINTER_ARRAY *pa)
if (pa->typelib.count)
{
pa->typelib.count=0;
- my_free((char*) pa->typelib.type_names,MYF(0));
+ my_free(pa->typelib.type_names);
pa->typelib.type_names=0;
- my_free(pa->str,MYF(0));
+ my_free(pa->str);
}
} /* free_pointer_array */
diff --git a/client/readline.cc b/client/readline.cc
index 73ce7c3b8c7..5c1a9951d9b 100644
--- a/client/readline.cc
+++ b/client/readline.cc
@@ -35,7 +35,7 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
return 0;
if (init_line_buffer(line_buff,my_fileno(file),IO_SIZE,max_size))
{
- my_free(line_buff,MYF(0));
+ my_free(line_buff);
return 0;
}
return line_buff;
@@ -63,8 +63,8 @@ void batch_readline_end(LINE_BUFFER *line_buff)
{
if (line_buff)
{
- my_free(line_buff->buffer,MYF(MY_ALLOW_ZERO_PTR));
- my_free(line_buff,MYF(0));
+ my_free(line_buff->buffer);
+ my_free(line_buff);
}
}
@@ -77,7 +77,7 @@ LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, char * str)
return 0;
if (init_line_buffer_from_string(line_buff,str))
{
- my_free(line_buff,MYF(0));
+ my_free(line_buff);
return 0;
}
return line_buff;
diff --git a/client/sql_string.h b/client/sql_string.h
index 1a3ac5d33c5..bafc287c73e 100644
--- a/client/sql_string.h
+++ b/client/sql_string.h
@@ -175,7 +175,7 @@ public:
{
alloced=0;
Alloced_length=0;
- my_free(Ptr,MYF(0));
+ my_free(Ptr);
Ptr=0;
str_length=0; /* Safety */
}