From 6cc9d0ffa0b6d9d0f19cf9445fad0e0ba11e38f8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 12 Dec 2011 22:58:24 +0100 Subject: move safemalloc out of dbug. remeber a real backtrace for every allocation. make safemalloc to tract C++ new/delete too. collateral fixes to make the test suite pass. --- client/mysqlimport.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'client/mysqlimport.c') diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 3b9939d7c6d..fabec74052d 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -62,6 +62,8 @@ static char *opt_plugin_dir= 0, *opt_default_auth= 0; static longlong opt_ignore_lines= -1; #include +static char **argv_to_free; + #ifdef HAVE_SMEM static char *shared_memory_base_name=0; #endif @@ -475,10 +477,18 @@ static void db_disconnect(char *host, MYSQL *mysql) static void safe_exit(int error, MYSQL *mysql) { - if (ignore_errors) + if (error && ignore_errors) return; if (mysql) mysql_close(mysql); + +#ifdef HAVE_SMEM + my_free(shared_memory_base_name); +#endif + free_defaults(argv_to_free); + mysql_library_end(); + my_free(opt_password); + my_end(my_end_arg); exit(error); } @@ -597,7 +607,6 @@ error: int main(int argc, char **argv) { int error=0; - char **argv_to_free; MY_INIT(argv[0]); if (load_defaults("my",load_default_groups,&argc,&argv)) @@ -687,11 +696,6 @@ int main(int argc, char **argv) exitcode= error; db_disconnect(current_host, mysql); } - my_free(opt_password); -#ifdef HAVE_SMEM - my_free(shared_memory_base_name); -#endif - free_defaults(argv_to_free); - my_end(my_end_arg); + safe_exit(0, 0); return(exitcode); } -- cgit v1.2.1