summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xBUILD/SETUP.sh4
-rwxr-xr-xBUILD/build_mccge.sh4
-rwxr-xr-xBUILD/compile-ia64-debug-max2
-rwxr-xr-xCMakeLists.txt9
-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
-rw-r--r--configure.in4
-rwxr-xr-xdbug/CMakeLists.txt2
-rw-r--r--dbug/Makefile.am2
-rw-r--r--dbug/dbug.c23
-rw-r--r--dbug/sanity.c13
-rw-r--r--dbug/user.r8
-rw-r--r--extra/comp_err.c24
-rw-r--r--extra/my_print_defaults.c2
-rw-r--r--extra/replace.c22
-rw-r--r--include/hash.h8
-rw-r--r--include/lf.h2
-rw-r--r--include/my_global.h10
-rw-r--r--include/my_list.h2
-rw-r--r--include/my_nosys.h2
-rw-r--r--include/my_sys.h82
-rw-r--r--include/mysql/psi/mysql_file.h4
-rw-r--r--libmysql/Makefile.am2
-rw-r--r--libmysql/Makefile.shared4
-rw-r--r--libmysql/libmysql.c16
-rw-r--r--libmysqld/lib_sql.cc12
-rw-r--r--libmysqld/libmysqld.c4
-rw-r--r--mysql-test/include/mysqld--help.inc2
-rw-r--r--mysql-test/lib/v1/mtr_report.pl14
-rwxr-xr-xmysql-test/lib/v1/mysql-test-run.pl4
-rwxr-xr-xmysql-test/mysql-stress-test.pl2
-rwxr-xr-xmysql-test/mysql-test-run.pl28
-rw-r--r--mysql-test/t/bug46080-master.opt2
-rw-r--r--mysql-test/t/mysql-bug45236-master.opt1
-rwxr-xr-xmysys/CMakeLists.txt4
-rw-r--r--mysys/Makefile.am5
-rw-r--r--mysys/array.c9
-rw-r--r--mysys/charset.c4
-rw-r--r--mysys/default_modify.c4
-rw-r--r--mysys/hash.c4
-rw-r--r--mysys/lf_alloc-pin.c2
-rw-r--r--mysys/lf_dynarray.c8
-rw-r--r--mysys/lf_hash.c4
-rw-r--r--mysys/list.c4
-rw-r--r--mysys/mf_cache.c10
-rw-r--r--mysys/mf_iocache.c4
-rw-r--r--mysys/mf_keycache.c12
-rw-r--r--mysys/mf_keycaches.c4
-rw-r--r--mysys/mf_sort.c2
-rw-r--r--mysys/mf_tempdir.c2
-rw-r--r--mysys/mf_wfile.c3
-rw-r--r--mysys/my_alloc.c6
-rw-r--r--mysys/my_bitmap.c2
-rw-r--r--mysys/my_compress.c12
-rw-r--r--mysys/my_error.c6
-rw-r--r--mysys/my_file.c2
-rw-r--r--mysys/my_fopen.c2
-rw-r--r--mysys/my_gethwaddr.c2
-rw-r--r--mysys/my_getopt.c10
-rw-r--r--mysys/my_init.c10
-rw-r--r--mysys/my_largepage.c11
-rw-r--r--mysys/my_lib.c8
-rw-r--r--mysys/my_lockmem.c5
-rw-r--r--mysys/my_malloc.c118
-rw-r--r--mysys/my_once.c4
-rw-r--r--mysys/my_open.c2
-rw-r--r--mysys/my_realloc.c75
-rw-r--r--mysys/my_windac.c8
-rw-r--r--mysys/queues.c7
-rw-r--r--mysys/safemalloc.c576
-rw-r--r--mysys/string.c7
-rw-r--r--mysys/test_charset.c4
-rw-r--r--mysys/testhash.c2
-rw-r--r--mysys/thr_alarm.c2
-rw-r--r--mysys/tree.c4
-rw-r--r--mysys/trie.c2
-rw-r--r--plugin/daemon_example/daemon_example.cc2
-rw-r--r--plugin/semisync/semisync_master.h2
-rw-r--r--scripts/mysql_config.pl.in3
-rw-r--r--scripts/mysql_config.sh3
-rw-r--r--sql-common/client.c110
-rw-r--r--sql/debug_sync.cc4
-rw-r--r--sql/derror.cc5
-rw-r--r--sql/event_data_objects.cc6
-rwxr-xr-xsql/event_scheduler.cc2
-rwxr-xr-xsql/examples/CMakeLists.txt4
-rw-r--r--sql/filesort.cc47
-rw-r--r--sql/gstream.h2
-rw-r--r--sql/ha_ndbcluster.cc44
-rw-r--r--sql/ha_ndbcluster_binlog.cc18
-rw-r--r--sql/ha_partition.cc10
-rw-r--r--sql/handler.cc12
-rw-r--r--sql/handler.h4
-rw-r--r--sql/item_func.cc10
-rw-r--r--sql/keycaches.cc6
-rw-r--r--sql/lock.cc12
-rw-r--r--sql/log.cc26
-rw-r--r--sql/log_event.cc34
-rw-r--r--sql/log_event.h12
-rw-r--r--sql/log_event_old.cc10
-rw-r--r--sql/mdl.cc4
-rw-r--r--sql/mysqld.cc20
-rw-r--r--sql/net_serv.cc4
-rw-r--r--sql/opt_range.cc10
-rw-r--r--sql/records.cc2
-rw-r--r--sql/repl_failsafe.cc4
-rw-r--r--sql/rpl_filter.cc4
-rw-r--r--sql/rpl_handler.cc4
-rw-r--r--sql/rpl_injector.cc2
-rw-r--r--sql/rpl_mi.cc2
-rw-r--r--sql/rpl_rli.cc2
-rw-r--r--sql/rpl_utility.cc2
-rw-r--r--sql/slave.cc8
-rw-r--r--sql/sp_pcontext.cc4
-rw-r--r--sql/sp_rcontext.cc4
-rw-r--r--sql/sql_base.cc18
-rw-r--r--sql/sql_binlog.cc2
-rw-r--r--sql/sql_cache.cc2
-rw-r--r--sql/sql_class.cc27
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_connect.cc7
-rw-r--r--sql/sql_db.cc19
-rw-r--r--sql/sql_handler.cc4
-rw-r--r--sql/sql_insert.cc12
-rw-r--r--sql/sql_lex.cc4
-rw-r--r--sql/sql_list.h2
-rw-r--r--sql/sql_load.cc4
-rw-r--r--sql/sql_locale.cc2
-rw-r--r--sql/sql_manager.cc2
-rw-r--r--sql/sql_map.cc2
-rw-r--r--sql/sql_parse.cc19
-rw-r--r--sql/sql_partition.cc2
-rw-r--r--sql/sql_plugin.cc30
-rw-r--r--sql/sql_plugin.h14
-rw-r--r--sql/sql_profile.cc6
-rw-r--r--sql/sql_profile.h4
-rw-r--r--sql/sql_select.cc10
-rw-r--r--sql/sql_show.cc12
-rw-r--r--sql/sql_string.h2
-rw-r--r--sql/sql_table.cc10
-rw-r--r--sql/sql_test.cc5
-rw-r--r--sql/sql_truncate.cc2
-rw-r--r--sql/sys_vars.h4
-rw-r--r--sql/table.cc40
-rw-r--r--sql/uniques.cc4
-rw-r--r--sql/unireg.cc22
-rw-r--r--storage/archive/archive_reader.c6
-rw-r--r--storage/archive/ha_archive.cc15
-rw-r--r--storage/blackhole/ha_blackhole.cc4
-rw-r--r--storage/csv/ha_tina.cc8
-rw-r--r--storage/csv/ha_tina.h2
-rw-r--r--storage/csv/transparent_file.cc2
-rw-r--r--storage/example/ha_example.cc4
-rw-r--r--storage/heap/ha_heap.cc4
-rw-r--r--storage/heap/hp_block.c2
-rw-r--r--storage/heap/hp_close.c2
-rw-r--r--storage/heap/hp_create.c6
-rw-r--r--storage/heap/hp_rename.c2
-rw-r--r--storage/ibmdb2i/db2i_constraints.cc2
-rw-r--r--storage/ibmdb2i/db2i_conversion.cc6
-rw-r--r--storage/ibmdb2i/db2i_file.cc15
-rw-r--r--storage/ibmdb2i/db2i_file.h2
-rw-r--r--storage/ibmdb2i/db2i_global.h2
-rw-r--r--storage/ibmdb2i/db2i_ileBridge.cc4
-rw-r--r--storage/ibmdb2i/db2i_ileBridge.h2
-rw-r--r--storage/ibmdb2i/ha_ibmdb2i.cc8
-rw-r--r--storage/innobase/handler/ha_innodb.cc33
-rw-r--r--storage/myisam/ft_boolean_search.c4
-rw-r--r--storage/myisam/ft_nlq_search.c2
-rw-r--r--storage/myisam/ft_stopwords.c6
-rw-r--r--storage/myisam/ha_myisam.cc4
-rw-r--r--storage/myisam/mi_check.c40
-rw-r--r--storage/myisam/mi_close.c12
-rw-r--r--storage/myisam/mi_create.c4
-rw-r--r--storage/myisam/mi_dynrec.c4
-rw-r--r--storage/myisam/mi_open.c4
-rw-r--r--storage/myisam/mi_packrec.c4
-rw-r--r--storage/myisam/mi_preload.c4
-rw-r--r--storage/myisam/mi_test2.c5
-rw-r--r--storage/myisam/mi_write.c4
-rw-r--r--storage/myisam/myisamchk.c7
-rw-r--r--storage/myisam/myisamlog.c12
-rw-r--r--storage/myisam/myisampack.c37
-rw-r--r--storage/myisam/rt_index.c2
-rw-r--r--storage/myisam/sort.c22
-rw-r--r--storage/myisammrg/ha_myisammrg.cc4
-rw-r--r--storage/myisammrg/myrg_close.c4
-rw-r--r--storage/myisammrg/myrg_open.c8
-rw-r--r--storage/ndb/config/win-lib.am2
-rw-r--r--storage/ndb/config/win-prg.am2
-rw-r--r--storage/ndb/include/util/NdbAutoPtr.hpp4
-rw-r--r--storage/ndb/src/mgmapi/mgmapi.cpp6
-rw-r--r--storage/ndb/src/mgmapi/ndb_logevent.cpp2
-rw-r--r--storage/ndb/test/ndbapi/testIndexStat.cpp6
-rw-r--r--storage/ndb/tools/restore/consumer_restore.cpp4
-rw-r--r--storage/perfschema/pfs.cc4
-rw-r--r--tests/mysql_client_test.c4
-rw-r--r--tests/thread_test.c2
-rw-r--r--unittest/mysys/CMakeLists.txt2
-rw-r--r--unittest/mysys/Makefile.am2
-rw-r--r--unittest/mysys/my_malloc-t.c43
-rw-r--r--vio/test-ssl.c24
-rw-r--r--vio/test-sslclient.c6
-rw-r--r--vio/test-sslserver.c4
-rw-r--r--vio/vio.c6
-rw-r--r--vio/viosslfactories.c10
-rw-r--r--vio/viotest-ssl.c24
217 files changed, 1012 insertions, 1821 deletions
diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh
index 626f932e045..cb61f9cfd70 100755
--- a/BUILD/SETUP.sh
+++ b/BUILD/SETUP.sh
@@ -122,13 +122,13 @@ fi
# Override -DFORCE_INIT_OF_VARS from debug_cflags. It enables the macro
# LINT_INIT(), which is only useful for silencing spurious warnings
# of static analysis tools. We want LINT_INIT() to be a no-op in Valgrind.
-valgrind_flags="-USAFEMALLOC -UFORCE_INIT_OF_VARS -DHAVE_purify "
+valgrind_flags="-UFORCE_INIT_OF_VARS -DHAVE_purify "
valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
valgrind_configs="--with-valgrind"
#
# Used in -debug builds
debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
-debug_cflags="$debug_cflags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC -DSAFE_MUTEX"
+debug_cflags="$debug_cflags -DSAFE_MUTEX"
error_inject="--with-error-inject "
#
# Base C++ flags for all builds
diff --git a/BUILD/build_mccge.sh b/BUILD/build_mccge.sh
index c3803610e73..b85252028ae 100755
--- a/BUILD/build_mccge.sh
+++ b/BUILD/build_mccge.sh
@@ -1010,7 +1010,7 @@ set_ccache_usage()
set_valgrind_flags()
{
if test "x$valgrind_flag" = "xyes" ; then
- loc_valgrind_flags="-USAFEMALLOC -UFORCE_INIT_OF_VARS -DHAVE_purify "
+ loc_valgrind_flags="-UFORCE_INIT_OF_VARS -DHAVE_purify "
loc_valgrind_flags="$loc_valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
compiler_flags="$compiler_flags $loc_valgrind_flags"
with_flags="$with_flags --with-valgrind"
@@ -1066,7 +1066,7 @@ set_with_debug_flags()
if test "x$with_debug_flag" = "xyes" ; then
if test "x$developer_flag" = "xyes" ; then
loc_debug_flags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
- loc_debug_flags="$loc_debug_flags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC"
+ loc_debug_flags="$loc_debug_flags"
compiler_flags="$compiler_flags $loc_debug_flags"
fi
fi
diff --git a/BUILD/compile-ia64-debug-max b/BUILD/compile-ia64-debug-max
index 123bfb06300..e9b534c302e 100755
--- a/BUILD/compile-ia64-debug-max
+++ b/BUILD/compile-ia64-debug-max
@@ -4,5 +4,5 @@ gmake -k maintainer-clean || true
path=`dirname $0`
. "$path/autorun.sh"
-CC=ecc CFLAGS="-w1 -DEXTRA_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -O2" CXX=ecc CXXFLAGS="-w1 -DEXTRA_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -O2" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-debug --with-innodb --with-embedded-server --with-archive-storage-engine
+CC=ecc CFLAGS="-w1 -DEXTRA_DEBUG -DSAFE_MUTEX -O2" CXX=ecc CXXFLAGS="-w1 -DEXTRA_DEBUG -DSAFE_MUTEX -O2" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-debug --with-innodb --with-embedded-server --with-archive-storage-engine
gmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0131ac1b0a7..cb71cb6aefc 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,7 @@ ENDIF()
SET(CUSTOM_C_FLAGS $ENV{CFLAGS})
OPTION(WITH_DEBUG "Use dbug/safemutex" OFF)
-OPTION(WITH_DEBUG_FULL "Use dbug and safemalloc/safemutex. Slow" OFF)
+OPTION(WITH_DEBUG_FULL "Use dbug and safemutex. Slow." OFF)
# Distinguish between community and non-community builds, with the
# default being a community build. This does not impact the feature
@@ -175,14 +175,13 @@ IF(NOT CMAKE_BUILD_TYPE
ENDIF()
ENDIF()
-# Add safemalloc and safemutex for debug condifurations, except on Windows
-# (C runtime library provides safemalloc functionality and safemutex has never
-# worked there)
+# Add safemutex for debug configurations, except on Windows
+# (safemutex has never worked on Windows)
IF(WITH_DEBUG OR WITH_DEBUG_FULL AND NOT WIN32)
FOREACH(LANG C CXX)
IF(WITH_DEBUG_FULL)
SET(CMAKE_${LANG}_FLAGS_DEBUG
- "${CMAKE_${LANG}_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+ "${CMAKE_${LANG}_FLAGS_DEBUG} -DSAFE_MUTEX")
ELSE()
SET(CMAKE_${LANG}_FLAGS_DEBUG
"${CMAKE_${LANG}_FLAGS_DEBUG} -DSAFE_MUTEX")
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 */
}
diff --git a/configure.in b/configure.in
index 3467d2d852d..4dbf858232a 100644
--- a/configure.in
+++ b/configure.in
@@ -1902,8 +1902,8 @@ elif test "$with_debug" = "full"
then
# Full debug. Very slow in some cases
AC_DEFINE([DBUG_ON], [1], [Use libdbug])
- CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS"
- CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS"
+ CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX $CFLAGS"
+ CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX $CXXFLAGS"
else
# Optimized version. No debug
AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug])
diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt
index 16e130fa28a..4cf6dd88cb7 100755
--- a/dbug/CMakeLists.txt
+++ b/dbug/CMakeLists.txt
@@ -17,6 +17,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/dbug
${CMAKE_SOURCE_DIR}/include
)
-SET(DBUG_SOURCES dbug.c sanity.c)
+SET(DBUG_SOURCES dbug.c)
ADD_CONVENIENCE_LIBRARY(dbug ${DBUG_SOURCES})
TARGET_LINK_LIBRARIES(dbug mysys)
diff --git a/dbug/Makefile.am b/dbug/Makefile.am
index 4091858a1af..3581b3597ee 100644
--- a/dbug/Makefile.am
+++ b/dbug/Makefile.am
@@ -19,7 +19,7 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
pkglib_LIBRARIES = libdbug.a
noinst_HEADERS = dbug_long.h
-libdbug_a_SOURCES = dbug.c sanity.c
+libdbug_a_SOURCES = dbug.c
EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
user.r monty.doc dbug_add_tags.pl \
my_main.c main.c factorial.c dbug_analyze.c \
diff --git a/dbug/dbug.c b/dbug/dbug.c
index 0355d553cff..a4b381f2746 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -128,9 +128,8 @@
#define PROFILE_ON (1 << 7) /* Print out profiling code */
#define PID_ON (1 << 8) /* Identify each line with process id */
#define TIMESTAMP_ON (1 << 9) /* timestamp every line of output */
-#define SANITY_CHECK_ON (1 << 10) /* Check safemalloc on DBUG_ENTER */
-#define FLUSH_ON_WRITE (1 << 11) /* Flush on every write */
-#define OPEN_APPEND (1 << 12) /* Open for append */
+#define FLUSH_ON_WRITE (1 << 10) /* Flush on every write */
+#define OPEN_APPEND (1 << 11) /* Open for append */
#define TRACE_ON ((uint)1 << 31) /* Trace enabled. MUST be the highest bit!*/
#define TRACING (cs->stack->flags & TRACE_ON)
@@ -184,12 +183,6 @@
static void perror(); /* Fake system/library error print routine */
#endif
-#ifdef SAFEMALLOC
-IMPORT int _sanity(const char *file,uint line); /* safemalloc sanity checker */
-#else
-#define _sanity(X,Y) (1)
-#endif
-
/*
* The user may specify a list of functions to trace or
* debug. These lists are kept in a linear linked list,
@@ -705,12 +698,6 @@ int DbugParse(CODE_STATE *cs, const char *control)
else
stack->flags |= TIMESTAMP_ON;
break;
- case 'S':
- if (sign < 0)
- stack->flags &= ~SANITY_CHECK_ON;
- else
- stack->flags |= SANITY_CHECK_ON;
- break;
}
if (!*end)
break;
@@ -1069,7 +1056,6 @@ int _db_explain_ (CODE_STATE *cs, char *buf, size_t len)
op_bool_to_buf('r', cs->stack->sub_level != 0);
op_intf_to_buf('t', cs->stack->maxdepth, MAXDEPTH, TRACING);
op_bool_to_buf('T', cs->stack->flags & TIMESTAMP_ON);
- op_bool_to_buf('S', cs->stack->flags & SANITY_CHECK_ON);
*buf= '\0';
return 0;
@@ -1187,8 +1173,6 @@ void _db_enter_(const char *_func_, const char *_file_,
if (!TRACING) break;
/* fall through */
case DO_TRACE:
- if ((cs->stack->flags & SANITY_CHECK_ON) && _sanity(_file_,_line_))
- cs->stack->flags &= ~SANITY_CHECK_ON;
if (TRACING)
{
if (!cs->locked)
@@ -1247,9 +1231,6 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
#endif
if (DoTrace(cs) & DO_TRACE)
{
- if ((cs->stack->flags & SANITY_CHECK_ON) &&
- _sanity(_stack_frame_->file,_line_))
- cs->stack->flags &= ~SANITY_CHECK_ON;
if (TRACING)
{
if (!cs->locked)
diff --git a/dbug/sanity.c b/dbug/sanity.c
deleted file mode 100644
index df43fc14ba9..00000000000
--- a/dbug/sanity.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Declarate _sanity() if not declared in main program */
-
-#include <my_global.h>
-
-extern int _sanity(const char *file,uint line);
-
-#if defined(SAFEMALLOC) && !defined(MASTER) /* Avoid errors in MySQL */
-int _sanity(const char * file __attribute__((unused)),
- uint line __attribute__((unused)))
-{
- return 0;
-}
-#endif
diff --git a/dbug/user.r b/dbug/user.r
index 847ad80b30f..5628f5a4fa1 100644
--- a/dbug/user.r
+++ b/dbug/user.r
@@ -1019,14 +1019,6 @@ Most useful with
.B DBUG_PUSH
macros used to temporarily alter the
debugger state.
-.LI S
-When compiled with
-.I safemalloc
-this flag forces "sanity" memory checks (for overwrites/underwrites)
-on each
-.B DBUG_ENTER
-and
-.B DBUG_RETURN.
.LI t[,N]
Enable function control flow tracing.
The maximum nesting depth is specified by N, and defaults to
diff --git a/extra/comp_err.c b/extra/comp_err.c
index 53d8c18262b..c85aef7bcc5 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -387,15 +387,15 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
struct errors *tmp_error, *next_error;
uint count, i;
- my_free((uchar*) default_language, MYF(0));
+ my_free((void*) default_language);
for (tmp_lang= lang_head; tmp_lang; tmp_lang= next_language)
{
next_language= tmp_lang->next_lang;
- my_free(tmp_lang->lang_short_name, MYF(0));
- my_free(tmp_lang->lang_long_name, MYF(0));
- my_free(tmp_lang->charset, MYF(0));
- my_free((uchar*) tmp_lang, MYF(0));
+ my_free(tmp_lang->lang_short_name);
+ my_free(tmp_lang->lang_long_name);
+ my_free(tmp_lang->charset);
+ my_free(tmp_lang);
}
for (tmp_error= error_head; tmp_error; tmp_error= next_error)
@@ -406,17 +406,17 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
{
struct message *tmp;
tmp= dynamic_element(&tmp_error->msg, i, struct message*);
- my_free((uchar*) tmp->lang_short_name, MYF(0));
- my_free((uchar*) tmp->text, MYF(0));
+ my_free(tmp->lang_short_name);
+ my_free(tmp->text);
}
delete_dynamic(&tmp_error->msg);
if (tmp_error->sql_code1[0])
- my_free((uchar*) tmp_error->sql_code1, MYF(0));
+ my_free((void*) tmp_error->sql_code1);
if (tmp_error->sql_code2[0])
- my_free((uchar*) tmp_error->sql_code2, MYF(0));
- my_free((uchar*) tmp_error->er_name, MYF(0));
- my_free((uchar*) tmp_error, MYF(0));
+ my_free((void*) tmp_error->sql_code2);
+ my_free((void*) tmp_error->er_name);
+ my_free(tmp_error);
}
}
@@ -559,7 +559,7 @@ static uint parse_error_offset(char *str)
end= 0;
ioffset= (uint) my_strtoll10(soffset, &end, &error);
- my_free((uchar*) soffset, MYF(0));
+ my_free(soffset);
DBUG_RETURN(ioffset);
}
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c
index 9595e1b2df8..81416df2922 100644
--- a/extra/my_print_defaults.c
+++ b/extra/my_print_defaults.c
@@ -200,7 +200,7 @@ int main(int argc, char **argv)
for (argument= arguments+1 ; *argument ; argument++)
if (*argument != args_separator) /* skip arguments separator */
puts(*argument);
- my_free((char*) load_default_groups,MYF(0));
+ my_free(load_default_groups);
free_defaults(arguments);
exit(0);
diff --git a/extra/replace.c b/extra/replace.c
index 3f07183807c..1a887ac3e21 100644
--- a/extra/replace.c
+++ b/extra/replace.c
@@ -262,7 +262,7 @@ static 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((uchar*) pa->typelib.type_names,MYF(0));
+ my_free(pa->typelib.type_names);
DBUG_RETURN (-1);
}
pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
@@ -324,9 +324,9 @@ static void free_pointer_array(reg1 POINTER_ARRAY *pa)
if (pa->typelib.count)
{
pa->typelib.count=0;
- my_free((uchar*) pa->typelib.type_names,MYF(0));
+ my_free(pa->typelib.type_names);
pa->typelib.type_names=0;
- my_free((uchar*) pa->str,MYF(0));
+ my_free(pa->str);
}
return;
} /* free_pointer_array */
@@ -441,7 +441,7 @@ static 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((uchar*) found_set,MYF(0));
+ my_free(found_set);
DBUG_RETURN(0);
}
@@ -663,9 +663,9 @@ static REPLACE *init_replace(char * *from, char * *to,uint count,
replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1));
}
}
- my_free((uchar*) follow,MYF(0));
+ my_free(follow);
free_sets(&sets);
- my_free((uchar*) found_set,MYF(0));
+ my_free(found_set);
DBUG_PRINT("exit",("Replace table has %d states",sets.count));
DBUG_RETURN(replace);
}
@@ -681,7 +681,7 @@ static 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((uchar*) sets->set,MYF(0));
+ my_free(sets->set);
return 1;
}
return 0;
@@ -742,8 +742,8 @@ static void free_last_set(REP_SETS *sets)
static void free_sets(REP_SETS *sets)
{
- my_free((uchar*)sets->set_buffer,MYF(0));
- my_free((uchar*)sets->bit_buffer,MYF(0));
+ my_free(sets->set_buffer);
+ my_free(sets->bit_buffer);
return;
}
@@ -950,8 +950,8 @@ static void reset_buffer()
static void free_buffer()
{
- my_free(buffer,MYF(MY_WME));
- my_free(out_buff,MYF(MY_WME));
+ my_free(buffer);
+ my_free(out_buff);
}
diff --git a/include/hash.h b/include/hash.h
index 7b4ec1b4685..d390cb7d4e6 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -64,14 +64,14 @@ typedef struct st_hash {
typedef uint HASH_SEARCH_STATE;
#define my_hash_init(A,B,C,D,E,F,G,H) \
- _my_hash_init(A,0,B,C,D,E,F,G,H CALLER_INFO)
+ _my_hash_init(A,0,B,C,D,E,F,G,H)
#define my_hash_init2(A,B,C,D,E,F,G,H,I) \
- _my_hash_init(A,B,C,D,E,F,G,H,I CALLER_INFO)
+ _my_hash_init(A,B,C,D,E,F,G,H,I)
my_bool _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
ulong default_array_elements, size_t key_offset,
size_t key_length, my_hash_get_key get_key,
void (*free_element)(void*),
- uint flags CALLER_INFO_PROTO);
+ uint flags);
void my_hash_free(HASH *tree);
void my_hash_reset(HASH *hash);
uchar *my_hash_element(HASH *hash, ulong idx);
@@ -100,7 +100,7 @@ my_bool my_hash_check(HASH *hash); /* Only in debug library */
#define my_hash_clear(H) bzero((char*) (H), sizeof(*(H)))
#define my_hash_inited(H) ((H)->blength != 0)
#define my_hash_init_opt(A,B,C,D,E,F,G,H) \
- (!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))
+ (!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G,H))
#ifdef __cplusplus
}
diff --git a/include/lf.h b/include/lf.h
index 7e8f05f4ada..d1f592d1047 100644
--- a/include/lf.h
+++ b/include/lf.h
@@ -204,7 +204,7 @@ uint lf_alloc_pool_count(LF_ALLOCATOR *allocator);
#define lf_alloc_get_pins(A) lf_pinbox_get_pins(&(A)->pinbox)
#define _lf_alloc_put_pins(PINS) _lf_pinbox_put_pins(PINS)
#define lf_alloc_put_pins(PINS) lf_pinbox_put_pins(PINS)
-#define lf_alloc_direct_free(ALLOC, ADDR) my_free((uchar*)(ADDR), MYF(0))
+#define lf_alloc_direct_free(ALLOC, ADDR) my_free((ADDR))
lock_wrap(lf_alloc_new, void *,
(LF_PINS *pins),
diff --git a/include/my_global.h b/include/my_global.h
index 7b9c34cd724..5e99c579bfd 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -889,11 +889,8 @@ typedef SOCKET_SIZE_TYPE size_socket;
How much overhead does malloc have. The code often allocates
something like 1024-MALLOC_OVERHEAD bytes
*/
-#ifdef SAFEMALLOC
-#define MALLOC_OVERHEAD (8+24+4)
-#else
#define MALLOC_OVERHEAD 8
-#endif
+
/* get memory in huncs */
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
/* Typical record cash */
@@ -1712,11 +1709,6 @@ inline void operator delete[](void*, void*) { /* Do nothing */ }
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
-#define x_free(A) \
- do { my_free((uchar*)(A), MYF(MY_WME|MY_FAE|MY_ALLOW_ZERO_PTR)); } while (0)
-#define safeFree(X) \
- do { if (X) { my_free((uchar*)(X), MYF(0)); (X) = NULL; } } while (0)
-
/*
Only Linux is known to need an explicit sync of the directory to make sure a
file creation/deletion/renaming in(from,to) this directory durable.
diff --git a/include/my_list.h b/include/my_list.h
index 775b56587b8..ff086e1725b 100644
--- a/include/my_list.h
+++ b/include/my_list.h
@@ -37,7 +37,7 @@ extern int list_walk(LIST *,list_walk_action action,unsigned char * argument);
#define list_rest(a) ((a)->next)
#define list_push(a,b) (a)=list_cons((b),(a))
-#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((unsigned char *) old,MYF(MY_FAE)); }
+#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old); my_free(old); }
#ifdef __cplusplus
}
diff --git a/include/my_nosys.h b/include/my_nosys.h
index df5639b81e2..ecb60333830 100644
--- a/include/my_nosys.h
+++ b/include/my_nosys.h
@@ -39,7 +39,7 @@ extern size_t my_quick_read(File Filedes,uchar *Buffer,size_t Count,
myf myFlags);
extern size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count);
-#if !defined(SAFEMALLOC) && defined(USE_HALLOC)
+#if defined(USE_HALLOC)
#define my_malloc(a,b) halloc(a,1)
#define my_no_flags_free(a) hfree(a)
#endif
diff --git a/include/my_sys.h b/include/my_sys.h
index 29c78289a1b..64b20753567 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -158,46 +158,15 @@ extern int NEAR my_errno; /* Last error in mysys */
#define GETDATE_FIXEDLENGTH 16
/* defines when allocating data */
-#ifdef SAFEMALLOC
-#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG )
-#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG )
-#define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG )
-#define my_checkmalloc() _sanity( __FILE__, __LINE__ )
-#define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG)
-#define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C)
-#define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C)
-#define my_strndup(A,B,C) _my_strndup((A),(B),__FILE__,__LINE__,C)
-#define TRASH(A,B) do { bfill(A, B, 0x8F); MEM_UNDEFINED(A, B); } while (0)
-#define QUICK_SAFEMALLOC sf_malloc_quick=1
-#define NORMAL_SAFEMALLOC sf_malloc_quick=0
-extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
-extern ulonglong sf_malloc_mem_limit;
-
-#define CALLER_INFO_PROTO , const char *sFile, uint uLine
-#define CALLER_INFO , __FILE__, __LINE__
-#define ORIG_CALLER_INFO , sFile, uLine
-#else
-#define my_checkmalloc()
-#undef TERMINATE
-#define TERMINATE(A,B) {}
-#define QUICK_SAFEMALLOC
-#define NORMAL_SAFEMALLOC
extern void *my_malloc(size_t Size,myf MyFlags);
-#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
+extern void *my_multi_malloc(myf MyFlags, ...);
extern void *my_realloc(void *oldpoint, size_t Size, myf MyFlags);
-extern void my_no_flags_free(void *ptr);
+extern void my_free(void *ptr);
extern void *my_memdup(const void *from,size_t length,myf MyFlags);
extern char *my_strdup(const char *from,myf MyFlags);
extern char *my_strndup(const char *from, size_t length,
myf MyFlags);
-/* we do use FG (as a no-op) in below so that a typo on FG is caught */
-#define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR))
-#define CALLER_INFO_PROTO /* nothing */
-#define CALLER_INFO /* nothing */
-#define ORIG_CALLER_INFO /* nothing */
#define TRASH(A,B) do{MEM_CHECK_ADDRESSABLE(A,B);MEM_UNDEFINED(A,B);} while (0)
-#endif
-
#if defined(ENABLED_DEBUG_SYNC)
extern void (*debug_sync_C_callback_ptr)(const char *, size_t);
#define DEBUG_SYNC_C(_sync_point_name_) do { \
@@ -211,11 +180,11 @@ extern void (*debug_sync_C_callback_ptr)(const char *, size_t);
#ifdef HAVE_LARGE_PAGES
extern uint my_get_large_page_size(void);
extern uchar * my_large_malloc(size_t size, myf my_flags);
-extern void my_large_free(uchar * ptr, myf my_flags);
+extern void my_large_free(uchar *ptr);
#else
#define my_get_large_page_size() (0)
#define my_large_malloc(A,B) my_malloc_lock((A),(B))
-#define my_large_free(A,B) my_free_lock((A),(B))
+#define my_large_free(A) my_free_lock((A))
#endif /* HAVE_LARGE_PAGES */
#ifdef HAVE_ALLOCA
@@ -233,7 +202,7 @@ extern void my_large_free(uchar * ptr, myf my_flags);
#define my_afree(PTR) {}
#else
#define my_alloca(SZ) my_malloc(SZ,MYF(0))
-#define my_afree(PTR) my_free(PTR,MYF(MY_WME))
+#define my_afree(PTR) my_free(PTR)
#endif /* HAVE_ALLOCA */
#ifndef errno /* did we already get it? */
@@ -642,20 +611,6 @@ extern size_t my_fwrite(FILE *stream,const uchar *Buffer,size_t Count,
myf MyFlags);
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
-extern void *_mymalloc(size_t uSize,const char *sFile,
- uint uLine, myf MyFlag);
-extern void *_myrealloc(void *pPtr,size_t uSize,const char *sFile,
- uint uLine, myf MyFlag);
-extern void * my_multi_malloc _VARARGS((myf MyFlags, ...));
-extern void _myfree(void *pPtr,const char *sFile,uint uLine, myf MyFlag);
-extern int _sanity(const char *sFile, uint uLine);
-extern void *_my_memdup(const void *from, size_t length,
- const char *sFile, uint uLine,myf MyFlag);
-extern char * _my_strdup(const char *from, const char *sFile, uint uLine,
- myf MyFlag);
-extern char *_my_strndup(const char *from, size_t length,
- const char *sFile, uint uLine,
- myf MyFlag);
/* implemented in my_memmem.c */
extern void *my_memmem(const void *haystack, size_t haystacklen,
@@ -684,9 +639,6 @@ extern HANDLE my_get_osfhandle(File fd);
extern void my_osmaperr(unsigned long last_error);
#endif
-#ifndef TERMINATE
-extern void TERMINATE(FILE *file, uint flag);
-#endif
extern void init_glob_errs(void);
extern const char** get_global_errmsgs();
extern void wait_for_free_space(const char *filename, int errors);
@@ -835,18 +787,16 @@ extern my_bool real_open_cached_file(IO_CACHE *cache);
extern void close_cached_file(IO_CACHE *cache);
File create_temp_file(char *to, const char *dir, const char *pfx,
int mode, myf MyFlags);
-#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D CALLER_INFO)
-#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D ORIG_CALLER_INFO)
-#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E CALLER_INFO)
-#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E ORIG_CALLER_INFO)
-extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array,uint element_size,
- void *init_buffer, uint init_alloc,
- uint alloc_increment
- CALLER_INFO_PROTO);
+#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
+#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
+#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
+#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
+extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
+ void *init_buffer, uint init_alloc,
+ uint alloc_increment);
/* init_dynamic_array() function is deprecated */
-extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
- uint init_alloc,uint alloc_increment
- CALLER_INFO_PROTO);
+extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
+ uint init_alloc, uint alloc_increment);
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,uchar * element);
extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array);
extern uchar *pop_dynamic(DYNAMIC_ARRAY*);
@@ -876,10 +826,10 @@ extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
extern void dynstr_free(DYNAMIC_STRING *str);
#ifdef HAVE_MLOCK
extern void *my_malloc_lock(size_t length,myf flags);
-extern void my_free_lock(void *ptr,myf flags);
+extern void my_free_lock(void *ptr);
#else
#define my_malloc_lock(A,B) my_malloc((A),(B))
-#define my_free_lock(A,B) my_free((A),(B))
+#define my_free_lock(A) my_free((A))
#endif
#define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h
index 94c8c323621..820979f16ee 100644
--- a/include/mysql/psi/mysql_file.h
+++ b/include/mysql/psi/mysql_file.h
@@ -800,7 +800,7 @@ inline_mysql_file_fopen(
#endif
if (unlikely(that->m_file == NULL))
{
- my_free(that, MYF(0));
+ my_free(that);
return NULL;
}
}
@@ -834,7 +834,7 @@ inline_mysql_file_fclose(
if (likely(locker != NULL))
PSI_server->end_file_wait(locker, (size_t) 0);
#endif
- my_free(file, MYF(0));
+ my_free(file);
}
return result;
}
diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am
index b1d23a175d4..8aa1648c834 100644
--- a/libmysql/Makefile.am
+++ b/libmysql/Makefile.am
@@ -79,7 +79,7 @@ link_sources:
# a minimal MySQL client library
#
# For a really minimal distribution (without debugging code) we could
-# keep only the stubs for safemalloc.c and debug.c
+# keep only the stubs for debug.c
#
# A list of needed headers collected from the deps information 000213
nh = my_global.h config-win32.h dbug.h errmsg.h \
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 71a4fd867bd..2b413831076 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -49,7 +49,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
ctype-uca.lo xml.lo my_strtoll10.lo str_alloc.lo dtoa.lo
mystringsextra= strto.c
-dbugobjects = dbug.lo # IT IS IN SAFEMALLOC.C sanity.lo
+dbugobjects = dbug.lo
mysysheaders = mysys_priv.h my_static.h
vioheaders = vio_priv.h
mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
@@ -57,7 +57,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
my_file.lo my_read.lo my_write.lo errors.lo \
my_error.lo my_getwd.lo my_div.lo \
mf_pack.lo my_mess.lo mf_dirname.lo mf_fn_ext.lo\
- mf_wcomp.lo typelib.lo safemalloc.lo my_alloc.lo \
+ mf_wcomp.lo typelib.lo my_alloc.lo \
mf_format.lo mf_path.lo mf_unixpath.lo my_fopen.lo \
my_symlink.lo my_fstream.lo mf_arr_appstr.lo \
mf_loadpath.lo my_pthread.lo my_thr_init.lo \
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 901fa1f0c4c..b69c27731dd 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -341,7 +341,7 @@ mysql_connect(MYSQL *mysql,const char *host,
if (!(res=mysql_real_connect(mysql,host,user,passwd,NullS,0,NullS,0)))
{
if (mysql->free_me)
- my_free((uchar*) mysql,MYF(0));
+ my_free(mysql);
}
mysql->reconnect= 1;
DBUG_RETURN(res);
@@ -457,9 +457,9 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
if (rc == 0)
{
/* Free old connect information */
- my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->user);
+ my_free(mysql->passwd);
+ my_free(mysql->db);
/* alloc new connect information */
mysql->user= my_strdup(user,MYF(MY_WME));
@@ -604,7 +604,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename)
err:
/* free up memory allocated with _init, usually */
(*options->local_infile_end)(li_ptr);
- my_free(buf, MYF(0));
+ my_free(buf);
DBUG_RETURN(result);
}
@@ -715,7 +715,7 @@ static void default_local_infile_end(void *ptr)
{
if (data->fd >= 0)
my_close(data->fd, MYF(MY_WME));
- my_free(ptr, MYF(MY_WME));
+ my_free(ptr);
}
}
@@ -2206,7 +2206,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
}
result= execute(stmt, param_data, length);
stmt->send_types_to_server=0;
- my_free(param_data, MYF(MY_WME));
+ my_free(param_data);
DBUG_RETURN(result);
}
DBUG_RETURN((int) execute(stmt,0,0));
@@ -4707,7 +4707,7 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
}
}
- my_free((uchar*) stmt, MYF(MY_WME));
+ my_free(stmt);
DBUG_RETURN(test(rc));
}
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index b36a97759d2..b8d855fcd45 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -76,7 +76,7 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data)
strmake(net->last_error, ei->info, sizeof(net->last_error)-1);
memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate));
mysql->server_status= ei->server_status;
- my_free(data, MYF(0));
+ my_free(data);
}
static my_bool
@@ -207,7 +207,7 @@ static MYSQL_FIELD *emb_list_fields(MYSQL *mysql)
res= ((THD*) mysql->thd)->cur_data;
((THD*) mysql->thd)->cur_data= 0;
mysql->field_alloc= res->alloc;
- my_free(res,MYF(0));
+ my_free(res);
mysql->status= MYSQL_STATUS_READY;
return mysql->fields;
}
@@ -236,7 +236,7 @@ static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
stmt->fields= mysql->fields;
stmt->mem_root= res->alloc;
mysql->fields= NULL;
- my_free(res,MYF(0));
+ my_free(res);
}
return 0;
@@ -293,7 +293,7 @@ static my_bool emb_read_query_result(MYSQL *mysql)
thd->cur_data= res;
}
else
- my_free(res, MYF(0));
+ my_free(res);
return 0;
}
@@ -335,7 +335,7 @@ int emb_read_binary_rows(MYSQL_STMT *stmt)
return 1;
}
stmt->result= *data;
- my_free((char *) data, MYF(0));
+ my_free(data);
set_stmt_errmsg(stmt, &stmt->mysql->net);
return 0;
}
@@ -590,7 +590,7 @@ int init_embedded_server(int argc, char **argv, char **groups)
void end_embedded_server()
{
- my_free((char*) copy_arguments_ptr, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(copy_arguments_ptr);
copy_arguments_ptr=0;
clean_up(0);
}
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index 8f7503c9d6c..758b803dbd4 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -119,8 +119,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
(mysql->options.my_cnf_file ?
mysql->options.my_cnf_file : "my"),
mysql->options.my_cnf_group);
- my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.my_cnf_file);
+ my_free(mysql->options.my_cnf_group);
mysql->options.my_cnf_file=mysql->options.my_cnf_group=0;
}
diff --git a/mysql-test/include/mysqld--help.inc b/mysql-test/include/mysqld--help.inc
index f21f8b20aa4..3c50e50ac0e 100644
--- a/mysql-test/include/mysqld--help.inc
+++ b/mysql-test/include/mysqld--help.inc
@@ -13,7 +13,7 @@ perl;
@skipvars=qw/basedir open-files-limit general-log-file log plugin-dir
log-slow-queries pid-file slow-query-log-file
datadir slave-load-tmpdir tmpdir/;
- @plugins=qw/innodb ndb archive blackhole federated partition ndbcluster safemalloc debug temp-pool ssl des-key-file
+ @plugins=qw/innodb ndb archive blackhole federated partition ndbcluster debug temp-pool ssl des-key-file
thread-concurrency super-large-pages mutex-deadlock-detector null-audit/;
@env=qw/MYSQLTEST_VARDIR MYSQL_TEST_DIR MYSQL_LIBDIR MYSQL_CHARSETSDIR MYSQL_SHAREDIR /;
$re1=join('|', @skipvars, @plugins);
diff --git a/mysql-test/lib/v1/mtr_report.pl b/mysql-test/lib/v1/mtr_report.pl
index 36aba983c34..84784ed19d4 100644
--- a/mysql-test/lib/v1/mtr_report.pl
+++ b/mysql-test/lib/v1/mtr_report.pl
@@ -253,19 +253,8 @@ sub mtr_report_stats ($) {
mtr_warning("can't read $errlog");
next;
}
- my $leak_reports_expected= undef;
while ( <ERR> )
{
- # There is a test case that purposely provokes a
- # SAFEMALLOC leak report, even though there is no actual
- # leak. We need to detect this, and ignore the warning in
- # that case.
- if (/Begin safemalloc memory dump:/) {
- $leak_reports_expected= 1;
- } elsif (/End safemalloc memory dump./) {
- $leak_reports_expected= undef;
- }
-
# Skip some non fatal warnings from the log files
if (
/\"SELECT UNIX_TIMESTAMP\(\)\" failed on master/ or
@@ -426,9 +415,6 @@ sub mtr_report_stats ($) {
}
if ( /$pattern/ )
{
- if ($leak_reports_expected) {
- next;
- }
$found_problems= 1;
print WARN basename($errlog) . ": $testname: $_";
}
diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl
index 64d7376605e..8a5edfbd762 100755
--- a/mysql-test/lib/v1/mysql-test-run.pl
+++ b/mysql-test/lib/v1/mysql-test-run.pl
@@ -3882,8 +3882,6 @@ sub mysqld_arguments ($$$$) {
if ( $opt_valgrind_mysqld )
{
- mtr_add_arg($args, "%s--loose-skip-safemalloc", $prefix);
-
if ( $mysql_version_id < 50100 )
{
mtr_add_arg($args, "%s--skip-bdb", $prefix);
@@ -4722,7 +4720,6 @@ sub run_check_testcase ($$) {
mtr_add_arg($args, "--no-defaults");
mtr_add_arg($args, "--silent");
- mtr_add_arg($args, "--skip-safemalloc");
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
@@ -4805,7 +4802,6 @@ sub run_mysqltest ($) {
mtr_add_arg($args, "--no-defaults");
mtr_add_arg($args, "--silent");
- mtr_add_arg($args, "--skip-safemalloc");
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
diff --git a/mysql-test/mysql-stress-test.pl b/mysql-test/mysql-stress-test.pl
index e51eba04525..504bee1ebbc 100755
--- a/mysql-test/mysql-stress-test.pl
+++ b/mysql-test/mysql-stress-test.pl
@@ -123,7 +123,7 @@ $pid_file="mysql_stress_test.pid";
$opt_mysqltest= ($^O =~ /mswin32/i) ? "mysqltest.exe" : "mysqltest";
$opt_check_tests_file="";
# OBM adding a setting for 'max-connect-retries=20' the default of 500 is to high
-@mysqltest_args=("--silent", "-v", "--skip-safemalloc", "--max-connect-retries=20");
+@mysqltest_args=("--silent", "-v", "--max-connect-retries=20");
# Client ip address
$client_ip=inet_ntoa((gethostbyname(hostname()))[4]);
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index c5cc3c5c295..1a574fe6e6b 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -3180,7 +3180,6 @@ sub start_run_one ($$) {
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
mtr_add_arg($args, "--silent");
- mtr_add_arg($args, "--skip-safemalloc");
mtr_add_arg($args, "--test-file=%s", "include/$run.test");
my $errfile= "$opt_vardir/tmp/$name.err";
@@ -3759,25 +3758,6 @@ sub extract_server_log ($$) {
}
$Ferr = undef; # Close error log file
- # mysql_client_test.test sends a COM_DEBUG packet to the server
- # to provoke a SAFEMALLOC leak report, ignore any warnings
- # between "Begin/end safemalloc memory dump"
- if ( grep(/Begin safemalloc memory dump:/, @lines) > 0)
- {
- my $discard_lines= 1;
- foreach my $line ( @lines )
- {
- if ($line =~ /Begin safemalloc memory dump:/){
- $discard_lines = 1;
- } elsif ($line =~ /End safemalloc memory dump./){
- $discard_lines = 0;
- }
-
- if ($discard_lines){
- $line = "ignored";
- }
- }
- }
return @lines;
}
@@ -3873,8 +3853,6 @@ sub start_check_warnings ($$) {
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
-
- mtr_add_arg($args, "--loose-skip-safemalloc");
mtr_add_arg($args, "--test-file=%s", "include/check-warnings.test");
if ( $opt_embedded_server )
@@ -4305,8 +4283,6 @@ sub mysqld_arguments ($$$) {
if ( $opt_valgrind_mysqld )
{
- mtr_add_arg($args, "--loose-skip-safemalloc");
-
if ( $mysql_version_id < 50100 )
{
mtr_add_arg($args, "--skip-bdb");
@@ -4899,9 +4875,6 @@ sub start_check_testcase ($$$) {
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
-
- mtr_add_arg($args, "--skip-safemalloc");
-
mtr_add_arg($args, "--result-file=%s", "$opt_vardir/tmp/$name.result");
mtr_add_arg($args, "--test-file=%s", "include/check-testcase.test");
mtr_add_arg($args, "--verbose");
@@ -4942,7 +4915,6 @@ sub start_mysqltest ($) {
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
mtr_add_arg($args, "--silent");
- mtr_add_arg($args, "--skip-safemalloc");
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
diff --git a/mysql-test/t/bug46080-master.opt b/mysql-test/t/bug46080-master.opt
index 71024d39356..1be97e178ed 100644
--- a/mysql-test/t/bug46080-master.opt
+++ b/mysql-test/t/bug46080-master.opt
@@ -1 +1 @@
---loose-performance-schema=0 --skip-grant-tables --skip-name-resolve --loose-safemalloc-mem-limit=4000000
+--loose-performance-schema=0 --skip-grant-tables --skip-name-resolve
diff --git a/mysql-test/t/mysql-bug45236-master.opt b/mysql-test/t/mysql-bug45236-master.opt
deleted file mode 100644
index fc1887bca47..00000000000
--- a/mysql-test/t/mysql-bug45236-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---loose-skip-safemalloc
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 0ea65ce8e4b..83615c82e2a 100755
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -29,10 +29,10 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
my_lib.c my_lock.c my_lockmem.c my_malloc.c my_mess.c
my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c
- my_quick.c my_read.c my_realloc.c my_redel.c my_rename.c my_seek.c my_sleep.c
+ my_quick.c my_read.c my_redel.c my_rename.c my_seek.c my_sleep.c
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c
my_write.c ptr_cmp.c queues.c stacktrace.c
- rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
+ rijndael.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
lf_alloc-pin.c lf_dynarray.c lf_hash.c
my_atomic.c my_getncpus.c
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index d5bffd874b2..f4fab89d5a5 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -29,9 +29,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_keycaches.c my_crc32.c \
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
- my_malloc.c my_realloc.c my_once.c mulalloc.c \
- my_alloc.c safemalloc.c my_new.cc \
- my_vle.c my_atomic.c lf_hash.c \
+ my_malloc.c my_once.c mulalloc.c \
+ my_alloc.c my_new.cc my_vle.c my_atomic.c lf_hash.c \
lf_dynarray.c lf_alloc-pin.c \
my_fopen.c my_fstream.c my_getsystime.c \
my_error.c errors.c my_div.c my_mess.c \
diff --git a/mysys/array.c b/mysys/array.c
index a1c49c2589d..70c7a59aa3a 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -42,7 +42,7 @@
my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
void *init_buffer, uint init_alloc,
- uint alloc_increment CALLER_INFO_PROTO)
+ uint alloc_increment)
{
DBUG_ENTER("init_dynamic_array");
if (!alloc_increment)
@@ -67,14 +67,13 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
Since the dynamic array is usable even if allocation fails here malloc
should not throw an error
*/
- if (!(array->buffer= (uchar*) my_malloc_ci(element_size*init_alloc, MYF(0))))
+ if (!(array->buffer= (uchar*) my_malloc(element_size*init_alloc, MYF(0))))
array->max_element=0;
DBUG_RETURN(FALSE);
}
my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
- uint init_alloc,
- uint alloc_increment CALLER_INFO_PROTO)
+ uint init_alloc, uint alloc_increment)
{
/* placeholder to preserve ABI */
return my_init_dynamic_array_ci(array, element_size, init_alloc,
@@ -306,7 +305,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array)
else
if (array->buffer)
{
- my_free(array->buffer,MYF(MY_WME));
+ my_free(array->buffer);
array->buffer=0;
array->elements=array->max_element=0;
}
diff --git a/mysys/charset.c b/mysys/charset.c
index 9f9d18e31a4..167d6b8ff6e 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -383,11 +383,11 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
#endif
}
- my_free(buf, myflags);
+ my_free(buf);
return FALSE;
error:
- my_free(buf, myflags);
+ my_free(buf);
return TRUE;
}
diff --git a/mysys/default_modify.c b/mysys/default_modify.c
index b214a1df445..edf4907cd4b 100644
--- a/mysys/default_modify.c
+++ b/mysys/default_modify.c
@@ -223,11 +223,11 @@ int modify_defaults_file(const char *file_location, const char *option,
if (my_fclose(cnf_file, MYF(MY_WME)))
DBUG_RETURN(1);
- my_free(file_buffer, MYF(0));
+ my_free(file_buffer);
DBUG_RETURN(0);
err:
- my_free(file_buffer, MYF(0));
+ my_free(file_buffer);
malloc_err:
my_fclose(cnf_file, MYF(0));
DBUG_RETURN(1); /* out of resources */
diff --git a/mysys/hash.c b/mysys/hash.c
index 39f3ad8d31e..f54ac1a4abb 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -67,8 +67,6 @@ static my_hash_value_type calc_hash(const HASH *hash,
@param[in] get_key get the key for the hash
@param[in] free_element pointer to the function that
does cleanup
- @param[in] CALLER_INFO_PROTO flag that define the behaviour
- of the hash
@return inidicates success or failure of initialization
@retval 0 success
@retval 1 failure
@@ -77,7 +75,7 @@ my_bool
_my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
ulong size, size_t key_offset, size_t key_length,
my_hash_get_key get_key,
- void (*free_element)(void*), uint flags CALLER_INFO_PROTO)
+ void (*free_element)(void*), uint flags)
{
DBUG_ENTER("my_hash_init");
DBUG_PRINT("enter",("hash: 0x%lx size: %u", (long) hash, (uint) size));
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c
index 7fd10703871..c264d3ac4c5 100644
--- a/mysys/lf_alloc-pin.c
+++ b/mysys/lf_alloc-pin.c
@@ -472,7 +472,7 @@ void lf_alloc_destroy(LF_ALLOCATOR *allocator)
uchar *tmp= anext_node(node);
if (allocator->destructor)
allocator->destructor(node);
- my_free((void *)node, MYF(0));
+ my_free(node);
node= tmp;
}
lf_pinbox_destroy(&allocator->pinbox);
diff --git a/mysys/lf_dynarray.c b/mysys/lf_dynarray.c
index b1cdce698a9..0941c8762bb 100644
--- a/mysys/lf_dynarray.c
+++ b/mysys/lf_dynarray.c
@@ -57,10 +57,10 @@ static void recursive_free(void **alloc, int level)
int i;
for (i= 0; i < LF_DYNARRAY_LEVEL_LENGTH; i++)
recursive_free(alloc[i], level-1);
- my_free((void *)alloc, MYF(0));
+ my_free(alloc);
}
else
- my_free(alloc[-1], MYF(0));
+ my_free(alloc[-1]);
}
void lf_dynarray_destroy(LF_DYNARRAY *array)
@@ -115,7 +115,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
if (my_atomic_casptr(ptr_ptr, &ptr, alloc))
ptr= alloc;
else
- my_free(alloc, MYF(0));
+ my_free(alloc);
}
ptr_ptr= ((void **)ptr) + idx / dynarray_idxes_in_prev_level[i];
idx%= dynarray_idxes_in_prev_level[i];
@@ -139,7 +139,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
if (my_atomic_casptr(ptr_ptr, &ptr, data))
ptr= data;
else
- my_free(alloc, MYF(0));
+ my_free(alloc);
}
return ((uchar*)ptr) + array->size_of_element * idx;
}
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index f478196c7c8..9c51ff1766e 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -344,7 +344,7 @@ void lf_hash_destroy(LF_HASH *hash)
if (el->hashnr & 1)
lf_alloc_direct_free(&hash->alloc, el); /* normal node */
else
- my_free((void *)el, MYF(0)); /* dummy node */
+ my_free(el); /* dummy node */
el= (LF_SLIST *)next;
}
lf_alloc_destroy(&hash->alloc);
@@ -489,7 +489,7 @@ static int initialize_bucket(LF_HASH *hash, LF_SLIST * volatile *node,
dummy->keylen= 0;
if ((cur= linsert(el, hash->charset, dummy, pins, LF_HASH_UNIQUE)))
{
- my_free((void *)dummy, MYF(0));
+ my_free(dummy);
dummy= cur;
}
my_atomic_casptr((void **)node, (void **)&tmp, dummy);
diff --git a/mysys/list.c b/mysys/list.c
index aaadd686365..e68fbf519d1 100644
--- a/mysys/list.c
+++ b/mysys/list.c
@@ -61,8 +61,8 @@ void list_free(LIST *root, uint free_data)
{
next=root->next;
if (free_data)
- my_free((uchar*) root->data,MYF(0));
- my_free((uchar*) root,MYF(0));
+ my_free(root->data);
+ my_free(root);
root=next;
}
}
diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c
index f0df0f3fa77..691532c0d80 100644
--- a/mysys/mf_cache.c
+++ b/mysys/mf_cache.c
@@ -71,8 +71,8 @@ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix,
{
DBUG_RETURN(0);
}
- my_free(cache->dir, MYF(MY_ALLOW_ZERO_PTR));
- my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(cache->dir);
+ my_free(cache->prefix);
DBUG_RETURN(1);
}
@@ -110,12 +110,12 @@ void close_cached_file(IO_CACHE *cache)
if (cache->file_name)
{
(void) my_delete(cache->file_name,MYF(MY_WME | ME_NOINPUT));
- my_free(cache->file_name,MYF(0));
+ my_free(cache->file_name);
}
#endif
}
- my_free(cache->dir,MYF(MY_ALLOW_ZERO_PTR));
- my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(cache->dir);
+ my_free(cache->prefix);
}
DBUG_VOID_RETURN;
}
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 620ac667a8b..daacc08044b 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -1831,7 +1831,7 @@ int end_io_cache(IO_CACHE *info)
info->alloced_buffer=0;
if (info->file != -1) /* File doesn't exist */
error= my_b_flush_io_cache(info,1);
- my_free((uchar*) info->buffer,MYF(MY_WME));
+ my_free(info->buffer);
info->buffer=info->read_pos=(uchar*) 0;
}
if (info->type == SEQ_READ_APPEND)
@@ -1917,7 +1917,7 @@ int main(int argc, char** argv)
total_bytes += 4+block_size;
}
close_file(&sra_cache);
- my_free(block,MYF(MY_WME));
+ my_free(block);
if (!my_stat(fname,&status,MYF(MY_WME)))
die("%s failed to stat, but I had just closed it,\
wonder how that happened");
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 9cbe3a21bce..5d0808933e3 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -446,7 +446,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
if ((keycache->block_root= (BLOCK_LINK*) my_malloc(length,
MYF(0))))
break;
- my_large_free(keycache->block_mem, MYF(0));
+ my_large_free(keycache->block_mem);
keycache->block_mem= 0;
}
if (blocks < 8)
@@ -521,12 +521,12 @@ err:
keycache->blocks= 0;
if (keycache->block_mem)
{
- my_large_free((uchar*) keycache->block_mem, MYF(0));
+ my_large_free((uchar*) keycache->block_mem);
keycache->block_mem= NULL;
}
if (keycache->block_root)
{
- my_free((uchar*) keycache->block_root, MYF(0));
+ my_free(keycache->block_root);
keycache->block_root= NULL;
}
my_errno= error;
@@ -747,9 +747,9 @@ void end_key_cache(KEY_CACHE *keycache, my_bool cleanup)
{
if (keycache->block_mem)
{
- my_large_free((uchar*) keycache->block_mem, MYF(0));
+ my_large_free((uchar*) keycache->block_mem);
keycache->block_mem= NULL;
- my_free((uchar*) keycache->block_root, MYF(0));
+ my_free(keycache->block_root);
keycache->block_root= NULL;
}
keycache->disk_blocks= -1;
@@ -4080,7 +4080,7 @@ restart:
#endif
err:
if (cache != cache_buff)
- my_free((uchar*) cache, MYF(0));
+ my_free(cache);
if (last_errno)
errno=last_errno; /* Return first error */
DBUG_RETURN(last_errno != 0);
diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c
index 999e8cc7975..ee4ad025b0b 100644
--- a/mysys/mf_keycaches.c
+++ b/mysys/mf_keycaches.c
@@ -71,7 +71,7 @@ typedef struct st_safe_hash_with_default
static void safe_hash_entry_free(SAFE_HASH_ENTRY *entry)
{
DBUG_ENTER("free_assign_entry");
- my_free((uchar*) entry, MYF(0));
+ my_free(entry);
DBUG_VOID_RETURN;
}
@@ -234,7 +234,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
if (my_hash_insert(&hash->hash, (uchar*) entry))
{
/* This can only happen if hash got out of memory */
- my_free((char*) entry, MYF(0));
+ my_free(entry);
error= 1;
goto end;
}
diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c
index 686ebbc1d14..a3e7465ead0 100644
--- a/mysys/mf_sort.c
+++ b/mysys/mf_sort.c
@@ -27,7 +27,7 @@ void my_string_ptr_sort(uchar *base, uint items, size_t size)
(ptr= (uchar**) my_malloc(items*sizeof(char*),MYF(0))))
{
radixsort_for_str_ptr((uchar**) base,items,size,ptr);
- my_free((uchar*) ptr,MYF(0));
+ my_free(ptr);
}
else
#endif
diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c
index 5633182ab3a..1c6c01cef9f 100644
--- a/mysys/mf_tempdir.c
+++ b/mysys/mf_tempdir.c
@@ -88,7 +88,7 @@ void free_tmpdir(MY_TMPDIR *tmpdir)
if (!tmpdir->full_list.elements)
return;
for (i=0; i<=tmpdir->max; i++)
- my_free(tmpdir->list[i], MYF(0));
+ my_free(tmpdir->list[i]);
delete_dynamic(&tmpdir->full_list);
mysql_mutex_destroy(&tmpdir->mutex);
}
diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c
index 4a4fb466600..95c4c006b2c 100644
--- a/mysys/mf_wfile.c
+++ b/mysys/mf_wfile.c
@@ -118,7 +118,6 @@ found:
void wf_end(WF_PACK *buffer)
{
DBUG_ENTER("wf_end");
- if (buffer)
- my_free(buffer, MYF(0));
+ my_free(buffer);
DBUG_VOID_RETURN;
} /* wf_end */
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index 19e51880209..903826dd975 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -120,7 +120,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
{
/* remove block from the list and free it */
*prev= mem->next;
- my_free(mem, MYF(0));
+ my_free(mem);
}
else
prev= &mem->next;
@@ -362,13 +362,13 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{
old=next; next= next->next ;
if (old != root->pre_alloc)
- my_free(old,MYF(0));
+ my_free(old);
}
for (next=root->free ; next ;)
{
old=next; next= next->next;
if (old != root->pre_alloc)
- my_free(old,MYF(0));
+ my_free(old);
}
root->used=root->free=0;
if (root->pre_alloc)
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 91370bd3727..25d2f3fda30 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -150,7 +150,7 @@ void bitmap_free(MY_BITMAP *map)
if (map->mutex)
mysql_mutex_destroy(map->mutex);
#endif
- my_free((char*) map->bitmap, MYF(0));
+ my_free(map->bitmap);
map->bitmap=0;
}
DBUG_VOID_RETURN;
diff --git a/mysys/my_compress.c b/mysys/my_compress.c
index a3d9d56915e..360390d376a 100644
--- a/mysys/my_compress.c
+++ b/mysys/my_compress.c
@@ -51,7 +51,7 @@ my_bool my_compress(uchar *packet, size_t *len, size_t *complen)
if (!compbuf)
DBUG_RETURN(*complen ? 0 : 1);
memcpy(packet,compbuf,*len);
- my_free(compbuf,MYF(MY_WME));
+ my_free(compbuf);
}
DBUG_RETURN(0);
}
@@ -73,14 +73,14 @@ uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen)
if (res != Z_OK)
{
- my_free(compbuf, MYF(MY_WME));
+ my_free(compbuf);
return 0;
}
if (*complen >= *len)
{
*complen= 0;
- my_free(compbuf, MYF(MY_WME));
+ my_free(compbuf);
DBUG_PRINT("note",("Packet got longer on compression; Not compressed"));
return 0;
}
@@ -125,11 +125,11 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen)
if (error != Z_OK)
{ /* Probably wrong packet */
DBUG_PRINT("error",("Can't uncompress packet, error: %d",error));
- my_free(compbuf, MYF(MY_WME));
+ my_free(compbuf);
DBUG_RETURN(1);
}
memcpy(packet, compbuf, *complen);
- my_free(compbuf, MYF(MY_WME));
+ my_free(compbuf);
}
else
*complen= len;
@@ -250,7 +250,7 @@ int unpackfrm(uchar **unpack_data, size_t *unpack_len,
if (my_uncompress(data, complen, &orglen))
{
- my_free(data, MYF(0));
+ my_free(data);
DBUG_RETURN(3);
}
diff --git a/mysys/my_error.c b/mysys/my_error.c
index e2523a39d0b..fa62cc604b6 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -211,7 +211,7 @@ int my_error_register(const char** (*get_errmsgs) (), int first, int last)
/* Error numbers must be unique. No overlapping is allowed. */
if (*search_meh_pp && ((*search_meh_pp)->meh_first <= last))
{
- my_free((uchar*)meh_p, MYF(0));
+ my_free(meh_p);
return 1;
}
@@ -267,7 +267,7 @@ const char **my_error_unregister(int first, int last)
/* Save the return value and free the header. */
errmsgs= meh_p->get_errmsgs();
- my_free((uchar*) meh_p, MYF(0));
+ my_free(meh_p);
return errmsgs;
}
@@ -282,7 +282,7 @@ void my_error_unregister_all(void)
/* We need this ptr, but we're about to free its container, so save it. */
saved_next= cursor->meh_next;
- my_free((uchar*) cursor, MYF(0));
+ my_free(cursor);
}
my_errmsgs_globerrs.meh_next= NULL; /* Freed in first iteration above. */
diff --git a/mysys/my_file.c b/mysys/my_file.c
index a31673b31bc..e4b7cd7779f 100644
--- a/mysys/my_file.c
+++ b/mysys/my_file.c
@@ -127,7 +127,7 @@ void my_free_open_file_info()
/* Copy data back for my_print_open_files */
memcpy((char*) my_file_info_default, my_file_info,
sizeof(*my_file_info_default)* MY_NFILE);
- my_free((char*) my_file_info, MYF(0));
+ my_free(my_file_info);
my_file_info= my_file_info_default;
my_file_limit= MY_NFILE;
}
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index 3f2bc08df65..861e4380690 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -117,7 +117,7 @@ int my_fclose(FILE *fd, myf MyFlags)
if ((uint) file < my_file_limit && my_file_info[file].type != UNOPEN)
{
my_file_info[file].type = UNOPEN;
- my_free(my_file_info[file].name, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(my_file_info[file].name);
}
mysql_mutex_unlock(&THR_LOCK_open);
DBUG_RETURN(err);
diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c
index c6a7af58f57..87e6519cafe 100644
--- a/mysys/my_gethwaddr.c
+++ b/mysys/my_gethwaddr.c
@@ -196,7 +196,7 @@ my_bool my_gethwaddr(uchar *to)
/* Clean up memory allocation. */
if (pAdapterAddresses != &adapterAddresses)
- my_free(pAdapterAddresses, 0);
+ my_free(pAdapterAddresses);
return return_val;
}
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 1e94dd2d761..f51dd7befd5 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -596,8 +596,7 @@ static int setval(const struct my_option *opts, void *value, char *argument,
case GET_STR_ALLOC:
if (argument == enabled_my_option)
break; /* string options don't use this default of "1" */
- if ((*((char**) value)))
- my_free((*(char**) value), MYF(MY_WME | MY_FAE));
+ my_free(*((char**) value));
if (!(*((char**) value)= my_strdup(argument, MYF(MY_WME))))
{
res= EXIT_OUT_OF_MEMORY;
@@ -1054,8 +1053,9 @@ static void init_one_value(const struct my_option *option, void *variable,
*/
if ((char*) (intptr) value)
{
- my_free((*(char**) variable), MYF(MY_ALLOW_ZERO_PTR));
- *((char**) variable)= my_strdup((char*) (intptr) value, MYF(MY_WME));
+ char **pstr= (char **) variable;
+ my_free(*pstr);
+ *pstr= my_strdup((char*) (intptr) value, MYF(MY_WME));
}
break;
default: /* dummy default to avoid compiler warnings */
@@ -1080,7 +1080,7 @@ static void fini_one_value(const struct my_option *option, void *variable,
DBUG_ENTER("fini_one_value");
switch ((option->var_type & GET_TYPE_MASK)) {
case GET_STR_ALLOC:
- my_free((*(char**) variable), MYF(MY_ALLOW_ZERO_PTR));
+ my_free(*((char**) variable));
*((char**) variable)= NULL;
break;
default: /* dummy default to avoid compiler warnings */
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 5bda2cb03ac..41a2efe0b90 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -141,6 +141,7 @@ my_bool my_init(void)
{
if (my_init_done)
return 0;
+
my_init_done= 1;
if (my_basic_init())
@@ -241,9 +242,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
#if defined(__NETWARE__) && !defined(__WIN__)
fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC);
#endif
-#if defined(SAFEMALLOC)
- TERMINATE(stderr, (infoflag & MY_GIVE_INFO) != 0);
-#elif defined(__WIN__) && defined(_MSC_VER)
+#if defined(__WIN__) && defined(_MSC_VER)
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
@@ -254,10 +253,6 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
_CrtDumpMemoryLeaks();
#endif
}
- else if (infoflag & MY_CHECK_ERROR)
- {
- TERMINATE(stderr, 0); /* Print memory leaks on screen */
- }
if (!(infoflag & MY_DONT_FREE_DBUG))
{
@@ -280,6 +275,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
if (have_tcpip)
WSACleanup();
#endif /* __WIN__ */
+
my_init_done=0;
my_basic_init_done= 0;
} /* my_end */
diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c
index e65d3a0a5f5..9f5ab01a2b7 100644
--- a/mysys/my_largepage.c
+++ b/mysys/my_largepage.c
@@ -27,7 +27,7 @@
static uint my_get_large_page_size_int(void);
static uchar* my_large_malloc_int(size_t size, myf my_flags);
-static my_bool my_large_free_int(uchar* ptr, myf my_flags);
+static my_bool my_large_free_int(uchar* ptr);
/* Gets the size of large pages from the OS */
@@ -70,7 +70,7 @@ uchar* my_large_malloc(size_t size, myf my_flags)
to my_free_lock() in case of failure
*/
-void my_large_free(uchar* ptr, myf my_flags __attribute__((unused)))
+void my_large_free(uchar* ptr)
{
DBUG_ENTER("my_large_free");
@@ -79,9 +79,8 @@ void my_large_free(uchar* ptr, myf my_flags __attribute__((unused)))
my_large_malloc_int(), i.e. my_malloc_lock() was used so we should free it
with my_free_lock()
*/
- if (!my_use_large_pages || !my_large_page_size ||
- !my_large_free_int(ptr, my_flags))
- my_free_lock(ptr, my_flags);
+ if (!my_use_large_pages || !my_large_page_size || !my_large_free_int(ptr))
+ my_free_lock(ptr);
DBUG_VOID_RETURN;
}
@@ -157,7 +156,7 @@ uchar* my_large_malloc_int(size_t size, myf my_flags)
/* Linux-specific large pages deallocator */
-my_bool my_large_free_int(uchar *ptr, myf my_flags __attribute__((unused)))
+my_bool my_large_free_int(uchar *ptr)
{
DBUG_ENTER("my_large_free_int");
DBUG_RETURN(shmdt(ptr) == 0);
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 0113d1498df..e70a70d47ed 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -77,7 +77,7 @@ void my_dirend(MY_DIR *buffer)
ALIGN_SIZE(sizeof(MY_DIR))));
free_root((MEM_ROOT*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)) +
ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))), MYF(0));
- my_free((uchar*) buffer,MYF(0));
+ my_free(buffer);
}
DBUG_VOID_RETURN;
} /* my_dirend */
@@ -131,7 +131,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT))
{
- my_free((uchar*) buffer,MYF(0));
+ my_free(buffer);
goto error;
}
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
@@ -400,7 +400,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT))
{
- my_free((uchar*) buffer,MYF(0));
+ my_free(buffer);
goto error;
}
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
@@ -547,7 +547,7 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
DBUG_PRINT("error",("Got errno: %d from stat", errno));
my_errno= errno;
if (m_used) /* Free if new area */
- my_free((uchar*) stat_area,MYF(0));
+ my_free(stat_area);
error:
if (my_flags & (MY_FAE+MY_WME))
diff --git a/mysys/my_lockmem.c b/mysys/my_lockmem.c
index 1b582783d33..a37db6b2089 100644
--- a/mysys/my_lockmem.c
+++ b/mysys/my_lockmem.c
@@ -74,7 +74,7 @@ uchar *my_malloc_lock(uint size,myf MyFlags)
}
-void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused)))
+void my_free_lock(uchar *ptr)
{
LIST *list;
struct st_mem_list *element=0;
@@ -91,8 +91,7 @@ void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused)))
}
}
mysql_mutex_unlock(&THR_LOCK_malloc);
- if (element)
- my_free((uchar*) element,MYF(0));
+ my_free(element);
free(ptr); /* Free even if not locked */
}
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index 13d2375eb99..fc2dc98c3c5 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -11,28 +11,31 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */
-#undef SAFEMALLOC
-#endif
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include "mysys_priv.h"
#include "mysys_err.h"
#include <m_string.h>
- /* My memory allocator */
+/**
+ Allocate a sized block of memory.
+ @param size The size of the memory block in bytes.
+ @param flags Failure action modifiers (bitmasks).
+
+ @return A pointer to the allocated memory block, or NULL on failure.
+*/
void *my_malloc(size_t size, myf my_flags)
{
void* point;
DBUG_ENTER("my_malloc");
DBUG_PRINT("my",("size: %lu my_flags: %d", (ulong) size, my_flags));
+ /* Safety */
if (!size)
- size=1; /* Safety */
+ size=1;
- point= (char *) malloc(size);
+ point= malloc(size);
DBUG_EXECUTE_IF("simulate_out_of_memory",
{
free(point);
@@ -52,33 +55,87 @@ void *my_malloc(size_t size, myf my_flags)
exit(1);
}
else if (my_flags & MY_ZEROFILL)
- bzero(point,size);
- DBUG_PRINT("exit",("ptr: 0x%lx", (long) point));
- DBUG_RETURN((void*) point);
-} /* my_malloc */
+ bzero(point, size);
+ DBUG_PRINT("exit",("ptr: %p", point));
+ DBUG_RETURN(point);
+}
+
+
+/**
+ @brief wrapper around realloc()
+
+ @param oldpoint pointer to currently allocated area
+ @param size new size requested, must be >0
+ @param my_flags flags
+
+ @note if size==0 realloc() may return NULL; my_realloc() treats this as an
+ error which is not the intention of realloc()
+*/
+void *my_realloc(void *oldpoint, size_t size, myf my_flags)
+{
+ void *point;
+ DBUG_ENTER("my_realloc");
+ DBUG_PRINT("my",("ptr: %p size: %lu my_flags: %d", oldpoint,
+ (ulong) size, my_flags));
+
+ DBUG_ASSERT(size > 0);
+ if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
+ DBUG_RETURN(my_malloc(size, my_flags));
+#ifdef USE_HALLOC
+ if (!(point = malloc(size)))
+ {
+ if (my_flags & MY_FREE_ON_ERROR)
+ my_free(oldpoint);
+ if (my_flags & MY_HOLD_ON_ERROR)
+ DBUG_RETURN(oldpoint);
+ my_errno=errno;
+ if (my_flags & MY_FAE+MY_WME)
+ my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
+ }
+ else
+ {
+ memcpy(point,oldpoint,size);
+ free(oldpoint);
+ }
+#else
+ if ((point= realloc(oldpoint, size)) == NULL)
+ {
+ if (my_flags & MY_FREE_ON_ERROR)
+ my_free(oldpoint);
+ if (my_flags & MY_HOLD_ON_ERROR)
+ DBUG_RETURN(oldpoint);
+ my_errno=errno;
+ if (my_flags & (MY_FAE+MY_WME))
+ my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size);
+ }
+#endif
+ DBUG_PRINT("exit",("ptr: %p", point));
+ DBUG_RETURN(point);
+}
- /* Free memory allocated with my_malloc */
- /*ARGSUSED*/
+/**
+ Free memory allocated with my_malloc.
-void my_no_flags_free(void* ptr)
+ @remark Relies on free being able to handle a NULL argument.
+
+ @param ptr Pointer to the memory allocated by my_malloc.
+*/
+void my_free(void *ptr)
{
DBUG_ENTER("my_free");
- DBUG_PRINT("my",("ptr: 0x%lx", (long) ptr));
- if (ptr)
- free(ptr);
+ DBUG_PRINT("my",("ptr: %p", ptr));
+ free(ptr);
DBUG_VOID_RETURN;
-} /* my_free */
-
+}
- /* malloc and copy */
-void* my_memdup(const void *from, size_t length, myf my_flags)
+void *my_memdup(const void *from, size_t length, myf my_flags)
{
void *ptr;
if ((ptr= my_malloc(length,my_flags)) != 0)
memcpy(ptr, from, length);
- return(ptr);
+ return ptr;
}
@@ -87,18 +144,19 @@ char *my_strdup(const char *from, myf my_flags)
char *ptr;
size_t length= strlen(from)+1;
if ((ptr= (char*) my_malloc(length, my_flags)))
- memcpy((uchar*) ptr, (uchar*) from,(size_t) length);
- return(ptr);
+ memcpy(ptr, from, length);
+ return ptr;
}
char *my_strndup(const char *from, size_t length, myf my_flags)
{
char *ptr;
- if ((ptr= (char*) my_malloc(length+1,my_flags)) != 0)
+ if ((ptr= (char*) my_malloc(length+1, my_flags)))
{
- memcpy((uchar*) ptr, (uchar*) from, length);
- ptr[length]=0;
+ memcpy(ptr, from, length);
+ ptr[length]= 0;
}
- return((char*) ptr);
+ return ptr;
}
+
diff --git a/mysys/my_once.c b/mysys/my_once.c
index 727b8477365..32d07802028 100644
--- a/mysys/my_once.c
+++ b/mysys/my_once.c
@@ -15,10 +15,6 @@
/* Not MT-SAFE */
-#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */
-#undef SAFEMALLOC
-#endif
-
#include "mysys_priv.h"
#include "my_static.h"
#include "mysys_err.h"
diff --git a/mysys/my_open.c b/mysys/my_open.c
index a50baf2c417..8f34ce1c6dc 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -88,7 +88,7 @@ int my_close(File fd, myf MyFlags)
}
if ((uint) fd < my_file_limit && my_file_info[fd].type != UNOPEN)
{
- my_free(my_file_info[fd].name, MYF(0));
+ my_free(my_file_info[fd].name);
#if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32)
mysql_mutex_destroy(&my_file_info[fd].mutex);
#endif
diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c
deleted file mode 100644
index a55282e03a0..00000000000
--- a/mysys/my_realloc.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */
-#undef SAFEMALLOC
-#endif
-
-#include "mysys_priv.h"
-#include "mysys_err.h"
-
- /* My memory re allocator */
-
-/**
- @brief wrapper around realloc()
-
- @param oldpoint pointer to currently allocated area
- @param size new size requested, must be >0
- @param my_flags flags
-
- @note if size==0 realloc() may return NULL; my_realloc() treats this as an
- error which is not the intention of realloc()
-*/
-void* my_realloc(void* oldpoint, size_t size, myf my_flags)
-{
- void *point;
- DBUG_ENTER("my_realloc");
- DBUG_PRINT("my",("ptr: 0x%lx size: %lu my_flags: %d", (long) oldpoint,
- (ulong) size, my_flags));
-
- DBUG_ASSERT(size > 0);
- if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
- DBUG_RETURN(my_malloc(size,my_flags));
-#ifdef USE_HALLOC
- if (!(point = malloc(size)))
- {
- 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 (my_flags & MY_FAE+MY_WME)
- my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
- }
- else
- {
- memcpy(point,oldpoint,size);
- free(oldpoint);
- }
-#else
- if ((point= (uchar*) realloc(oldpoint,size)) == NULL)
- {
- 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 (my_flags & (MY_FAE+MY_WME))
- my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size);
- }
-#endif
- DBUG_PRINT("exit",("ptr: 0x%lx", (long) point));
- DBUG_RETURN(point);
-} /* my_realloc */
diff --git a/mysys/my_windac.c b/mysys/my_windac.c
index f846853f7be..0c924188623 100644
--- a/mysys/my_windac.c
+++ b/mysys/my_windac.c
@@ -194,8 +194,8 @@ error:
FreeSid(everyone_sid);
if (htoken)
CloseHandle(htoken);
- my_free((uchar*) sa, MYF(MY_ALLOW_ZERO_PTR));
- my_free((uchar*) dacl, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(sa);
+ my_free(dacl);
*psa= 0;
return 1;
}
@@ -215,8 +215,8 @@ void my_security_attr_free(SECURITY_ATTRIBUTES *sa)
My_security_attr *attr= (My_security_attr*)
(((char*)sa) + ALIGN_SIZE(sizeof(*sa)));
FreeSid(attr->everyone_sid);
- my_free((uchar*) attr->dacl, MYF(0));
- my_free((uchar*) sa, MYF(0));
+ my_free(attr->dacl);
+ my_free(sa);
}
}
diff --git a/mysys/queues.c b/mysys/queues.c
index 9c85e493141..25a310c0752 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -194,11 +194,8 @@ int resize_queue(QUEUE *queue, uint max_elements)
void delete_queue(QUEUE *queue)
{
DBUG_ENTER("delete_queue");
- if (queue->root)
- {
- my_free((uchar*) queue->root,MYF(0));
- queue->root=0;
- }
+ my_free(queue->root);
+ queue->root= NULL;
DBUG_VOID_RETURN;
}
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c
deleted file mode 100644
index 6d0f7e5dd53..00000000000
--- a/mysys/safemalloc.c
+++ /dev/null
@@ -1,576 +0,0 @@
-/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/*
- * Memory sub-system, written by Bjorn Benson
- Fixed to use my_sys scheme by Michael Widenius
-
- [This posting refers to an article entitled "oops, corrupted memory
- again!" in net.lang.c. I am posting it here because it is source.]
-
- My tool for approaching this problem is to build another level of data
- abstraction on top of malloc() and free() that implements some checking.
- This does a number of things for you:
- - Checks for overruns and underruns on allocated data
- - Keeps track of where in the program the memory was malloc'ed
- - Reports on pieces of memory that were not free'ed
- - Records some statistics such as maximum memory used
- - Marks newly malloc'ed and newly free'ed memory with special values
- You can use this scheme to:
- - Find bugs such as overrun, underrun, etc because you know where
- a piece of data was malloc'ed and where it was free'ed
- - Find bugs where memory was not free'ed
- - Find bugs where newly malloc'ed memory is used without initializing
- - Find bugs where newly free'ed memory is still used
- - Determine how much memory your program really uses
- - and other things
-
- To implement my scheme you must have a C compiler that has __LINE__ and
- __FILE__ macros. If your compiler doesn't have these then (a) buy another:
- compilers that do are available on UNIX 4.2bsd based systems and the PC,
- and probably on other machines; or (b) change my scheme somehow. I have
- recomendations on both these points if you would like them (e-mail please).
-
- There are 4 functions in my package:
- char *NEW( uSize ) Allocate memory of uSize bytes
- (equivalent to malloc())
- char *REA( pPtr, uSize) Allocate memory of uSize bytes, move data and
- free pPtr.
- (equivalent to realloc())
- FREE( pPtr ) Free memory allocated by NEW
- (equivalent to free())
- TERMINATE(file,flag) End system, report errors and stats on file
- I personally use two more functions, but have not included them here:
- char *STRSAVE( sPtr ) Save a copy of the string in dynamic memory
- char *RENEW( pPtr, uSize )
- (equivalent to realloc())
-
-*/
-
-#ifndef SAFEMALLOC
-#define SAFEMALLOC /* Get protos from my_sys */
-#endif
-
-#include "mysys_priv.h"
-#include <m_string.h>
-#include "my_static.h"
-#include "mysys_err.h"
-
-ulonglong sf_malloc_mem_limit= ~(ulonglong)0;
-
-#ifndef PEDANTIC_SAFEMALLOC
-/*
- Set to 1 after TERMINATE() if we had to fiddle with sf_malloc_count and
- the linked list of blocks so that _sanity() will not fuss when it
- is not supposed to
-*/
-static int sf_malloc_tampered= 0;
-#endif
-
-
- /* Static functions prototypes */
-
-static int check_ptr(const char *where, uchar *ptr, const char *sFile,
- uint uLine);
-static int _checkchunk(struct st_irem *pRec, const char *sFile, uint uLine);
-
-/*
- Note: We only fill up the allocated block. This do not include
- malloc() roundoff or the extra space required by the irem
- structures.
-*/
-
-/*
- NEW'ed memory is filled with this value so that references to it will
- end up being very strange.
-*/
-#define ALLOC_VAL (uchar) 0xA5
-/*
- FEEE'ed memory is filled with this value so that references to it will
- end up being very strange.
-*/
-#define FREE_VAL (uchar) 0x8F
-#define MAGICKEY 0x14235296 /* A magic value for underrun key */
-
-/*
- Warning: do not change the MAGICEND? values to something with the
- high bit set. Various C compilers (like the 4.2bsd one) do not do
- the sign extension right later on in this code and you will get
- erroneous errors.
-*/
-
-#define MAGICEND0 0x68 /* Magic values for overrun keys */
-#define MAGICEND1 0x34 /* " */
-#define MAGICEND2 0x7A /* " */
-#define MAGICEND3 0x15 /* " */
-
-
-/* Allocate some memory. */
-
-void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags)
-{
- struct st_irem *irem;
- uchar *data;
- DBUG_ENTER("_mymalloc");
- DBUG_PRINT("enter",("Size: %lu", (ulong) size));
-
- if (!sf_malloc_quick)
- (void) _sanity (filename, lineno);
-
- if (size + sf_malloc_cur_memory > sf_malloc_mem_limit)
- irem= 0;
- else
- {
- /* Allocate the physical memory */
- irem= (struct st_irem *) malloc (ALIGN_SIZE(sizeof(struct st_irem)) +
- sf_malloc_prehunc +
- size + /* size requested */
- 4 + /* overrun mark */
- sf_malloc_endhunc);
- DBUG_EXECUTE_IF("simulate_out_of_memory",
- {
- free(irem);
- irem= NULL;
- });
- }
- /* Check if there isn't anymore memory avaiable */
- if (!irem)
- {
- if (MyFlags & MY_FAE)
- error_handler_hook=fatal_error_handler_hook;
- if (MyFlags & (MY_FAE+MY_WME))
- {
- char buff[256];
- my_errno=errno;
- sprintf(buff,"Out of memory at line %d, '%s'", lineno, filename);
- my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH));
- sprintf(buff,"needed %lu byte (%luk), memory in use: %lu bytes (%luk)",
- (ulong) size, (ulong) (size + 1023L) / 1024L,
- (ulong) sf_malloc_max_memory,
- (ulong) (sf_malloc_max_memory + 1023L) / 1024L);
- my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH));
- }
- DBUG_PRINT("error",("Out of memory, in use: %ld at line %d, '%s'",
- (long)sf_malloc_max_memory,lineno, filename));
- DBUG_EXECUTE_IF("simulate_out_of_memory",
- DBUG_SET("-d,simulate_out_of_memory"););
- if (MyFlags & MY_FAE)
- exit(1);
- DBUG_RETURN ((void*) 0);
- }
-
- /* Fill up the structure */
- data= (((uchar*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) +
- sf_malloc_prehunc);
- *((uint32*) (data-sizeof(uint32)))= MAGICKEY;
- data[size + 0]= MAGICEND0;
- data[size + 1]= MAGICEND1;
- data[size + 2]= MAGICEND2;
- data[size + 3]= MAGICEND3;
- irem->filename= (char *) filename;
- irem->linenum= lineno;
- irem->datasize= size;
- irem->prev= NULL;
-
- /* Add this remember structure to the linked list */
- mysql_mutex_lock(&THR_LOCK_malloc);
- if ((irem->next= sf_malloc_root))
- sf_malloc_root->prev= irem;
- sf_malloc_root= irem;
-
- /* Keep the statistics */
- sf_malloc_cur_memory+= size;
- if (sf_malloc_cur_memory > sf_malloc_max_memory)
- sf_malloc_max_memory= sf_malloc_cur_memory;
- sf_malloc_count++;
- mysql_mutex_unlock(&THR_LOCK_malloc);
-
- MEM_CHECK_ADDRESSABLE(data, size);
- /* Set the memory to the aribtrary wierd value */
- if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick)
- bfill(data, size, (char) (MyFlags & MY_ZEROFILL ? 0 : ALLOC_VAL));
- if (!(MyFlags & MY_ZEROFILL))
- MEM_UNDEFINED(data, size);
- /* Return a pointer to the real data */
- DBUG_PRINT("exit",("ptr: %p", data));
- if (sf_min_adress > data)
- sf_min_adress= data;
- if (sf_max_adress < data)
- sf_max_adress= data;
- DBUG_RETURN((void*) data);
-}
-
-
-/*
- Allocate some new memory and move old memoryblock there.
- Free then old memoryblock
-*/
-
-void *_myrealloc(register void *ptr, register size_t size,
- const char *filename, uint lineno, myf MyFlags)
-{
- struct st_irem *irem;
- char *data;
- DBUG_ENTER("_myrealloc");
-
- if (!ptr && (MyFlags & MY_ALLOW_ZERO_PTR))
- DBUG_RETURN(_mymalloc(size, filename, lineno, MyFlags));
-
- if (!sf_malloc_quick)
- (void) _sanity (filename, lineno);
-
- if (check_ptr("Reallocating", (uchar*) ptr, filename, lineno))
- DBUG_RETURN((uchar*) NULL);
-
- irem= (struct st_irem *) (((char*) ptr) - ALIGN_SIZE(sizeof(struct st_irem))-
- sf_malloc_prehunc);
- if (*((uint32*) (((char*) ptr)- sizeof(uint32))) != MAGICKEY)
- {
- fprintf(stderr, "Error: Reallocating unallocated data at line %d, '%s'\n",
- lineno, filename);
- DBUG_PRINT("safe",("Reallocating unallocated data at line %d, '%s'",
- lineno, filename));
- (void) fflush(stderr);
- DBUG_RETURN((uchar*) NULL);
- }
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
- size=min(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
- else
- {
- if (MyFlags & MY_HOLD_ON_ERROR)
- DBUG_RETURN(ptr);
- if (MyFlags & MY_FREE_ON_ERROR)
- _myfree(ptr, filename, lineno, 0);
- }
- DBUG_RETURN(data);
-} /* _myrealloc */
-
-
-/* Deallocate some memory. */
-
-void _myfree(void *ptr, const char *filename, uint lineno, myf myflags)
-{
- struct st_irem *irem;
- DBUG_ENTER("_myfree");
- DBUG_PRINT("enter",("ptr: %p", ptr));
-
- if (!sf_malloc_quick)
- (void) _sanity (filename, lineno);
-
- if ((!ptr && (myflags & MY_ALLOW_ZERO_PTR)) ||
- check_ptr("Freeing",(uchar*) ptr,filename,lineno))
- DBUG_VOID_RETURN;
-
- /* Calculate the address of the remember structure */
- irem= (struct st_irem *) ((char*) ptr- ALIGN_SIZE(sizeof(struct st_irem))-
- sf_malloc_prehunc);
-
- /*
- Check to make sure that we have a real remember structure.
- Note: this test could fail for four reasons:
- (1) The memory was already free'ed
- (2) The memory was never new'ed
- (3) There was an underrun
- (4) A stray pointer hit this location
- */
-
- if (*((uint32*) ((char*) ptr- sizeof(uint32))) != MAGICKEY)
- {
- fprintf(stderr, "Error: Freeing unallocated data at line %d, '%s'\n",
- lineno, filename);
- DBUG_PRINT("safe",("Unallocated data at line %d, '%s'",lineno,filename));
- (void) fflush(stderr);
- DBUG_VOID_RETURN;
- }
-
- /* Remove this structure from the linked list */
- mysql_mutex_lock(&THR_LOCK_malloc);
- if (irem->prev)
- irem->prev->next= irem->next;
- else
- sf_malloc_root= irem->next;
-
- if (irem->next)
- irem->next->prev= irem->prev;
- /* Handle the statistics */
- sf_malloc_cur_memory-= irem->datasize;
- sf_malloc_count--;
- mysql_mutex_unlock(&THR_LOCK_malloc);
-
-#ifndef HAVE_purify
- /* Mark this data as free'ed */
- if (!sf_malloc_quick)
- bfill(ptr, irem->datasize, (pchar) FREE_VAL);
-#endif
- MEM_NOACCESS(ptr, irem->datasize);
- *((uint32*) ((char*) ptr- sizeof(uint32)))= ~MAGICKEY;
- MEM_NOACCESS((char*) ptr - sizeof(uint32), sizeof(uint32));
- /* Actually free the memory */
- free((char*) irem);
- DBUG_VOID_RETURN;
-}
-
- /* Check if we have a wrong pointer */
-
-static int check_ptr(const char *where, uchar *ptr, const char *filename,
- uint lineno)
-{
- if (!ptr)
- {
- fprintf(stderr, "Error: %s NULL pointer at line %d, '%s'\n",
- where,lineno, filename);
- DBUG_PRINT("safe",("Null pointer at line %d '%s'", lineno, filename));
- (void) fflush(stderr);
- return 1;
- }
-#ifndef _MSC_VER
- if ((long) ptr & (ALIGN_SIZE(1)-1))
- {
- fprintf(stderr, "Error: %s wrong aligned pointer at line %d, '%s'\n",
- where,lineno, filename);
- DBUG_PRINT("safe",("Wrong aligned pointer at line %d, '%s'",
- lineno,filename));
- (void) fflush(stderr);
- return 1;
- }
-#endif
- if (ptr < sf_min_adress || ptr > sf_max_adress)
- {
- fprintf(stderr, "Error: %s pointer out of range at line %d, '%s'\n",
- where,lineno, filename);
- DBUG_PRINT("safe",("Pointer out of range at line %d '%s'",
- lineno,filename));
- (void) fflush(stderr);
- return 1;
- }
- return 0;
-}
-
-
-/*
- Report on all the memory pieces that have not been free'ed
-
- SYNOPSIS
- TERMINATE()
- file Write output to this file
- flag If <> 0, also write statistics
- */
-
-void TERMINATE(FILE *file, uint flag)
-{
- struct st_irem *irem;
- DBUG_ENTER("TERMINATE");
- mysql_mutex_lock(&THR_LOCK_malloc);
-
- /*
- Report the difference between number of calls to
- NEW and the number of calls to FREE. >0 means more
- NEWs than FREEs. <0, etc.
- */
-
- if (sf_malloc_count)
- {
- if (file)
- {
- fprintf(file, "Warning: Not freed memory segments: %u\n", sf_malloc_count);
- (void) fflush(file);
- }
- DBUG_PRINT("safe",("sf_malloc_count: %u", sf_malloc_count));
- }
-
- /*
- Report on all the memory that was allocated with NEW
- but not free'ed with FREE.
- */
-
- if ((irem= sf_malloc_root))
- {
- if (file)
- {
- fprintf(file, "Warning: Memory that was not free'ed (%lu bytes):\n",
- (ulong) sf_malloc_cur_memory);
- (void) fflush(file);
- }
- DBUG_PRINT("safe",("Memory that was not free'ed (%lu bytes):",
- (ulong) sf_malloc_cur_memory));
- while (irem)
- {
- char *data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) +
- sf_malloc_prehunc);
- if (file)
- {
- fprintf(file,
- "\t%6lu bytes at %p, allocated at line %4u in '%s'",
- (ulong) irem->datasize, data, irem->linenum, irem->filename);
- fprintf(file, "\n");
- (void) fflush(file);
- }
- DBUG_PRINT("safe",
- ("%6lu bytes at %p, allocated at line %4d in '%s'",
- (ulong) irem->datasize,
- data, irem->linenum, irem->filename));
- irem= irem->next;
- }
- }
- /* Report the memory usage statistics */
- if (file && flag)
- {
- fprintf(file, "Maximum memory usage: %lu bytes (%luk)\n",
- (ulong) sf_malloc_max_memory,
- (ulong) (sf_malloc_max_memory + 1023L) / 1024L);
- (void) fflush(file);
- }
- DBUG_PRINT("safe",("Maximum memory usage: %lu bytes (%luk)",
- (ulong) sf_malloc_max_memory,
- (ulong) (sf_malloc_max_memory + 1023L) /1024L));
- mysql_mutex_unlock(&THR_LOCK_malloc);
- DBUG_VOID_RETURN;
-}
-
-
-/*
- Report where a piece of memory was allocated
-
- This is usefull to call from withing a debugger
-*/
-
-
-void sf_malloc_report_allocated(void *memory)
-{
- struct st_irem *irem;
- for (irem= sf_malloc_root ; irem ; irem=irem->next)
- {
- char *data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) +
- sf_malloc_prehunc);
- if (data <= (char*) memory && (char*) memory <= data + irem->datasize)
- {
- printf("%lu bytes at %p, allocated at line %u in '%s'\n",
- (ulong) irem->datasize, data, irem->linenum, irem->filename);
- break;
- }
- }
-}
-
- /* Returns 0 if chunk is ok */
-
-static int _checkchunk(register struct st_irem *irem, const char *filename,
- uint lineno)
-{
- int flag=0;
- char *magicp, *data;
-
- data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) +
- sf_malloc_prehunc);
- /* Check for a possible underrun */
- if (*((uint32*) (data- sizeof(uint32))) != MAGICKEY)
- {
- fprintf(stderr, "Error: Memory allocated at %s:%d was underrun,",
- irem->filename, irem->linenum);
- fprintf(stderr, " discovered at %s:%d\n", filename, lineno);
- (void) fflush(stderr);
- DBUG_PRINT("safe",("Underrun at %p, allocated at %s:%d",
- data, irem->filename, irem->linenum));
- flag=1;
- }
-
- /* Check for a possible overrun */
- magicp= data + irem->datasize;
- if (*magicp++ != MAGICEND0 ||
- *magicp++ != MAGICEND1 ||
- *magicp++ != MAGICEND2 ||
- *magicp++ != MAGICEND3)
- {
- fprintf(stderr, "Error: Memory allocated at %s:%d was overrun,",
- irem->filename, irem->linenum);
- fprintf(stderr, " discovered at '%s:%d'\n", filename, lineno);
- (void) fflush(stderr);
- DBUG_PRINT("safe",("Overrun at %p, allocated at %s:%d",
- data, irem->filename, irem->linenum));
- flag=1;
- }
- return(flag);
-}
-
-
- /* Returns how many wrong chunks */
-
-int _sanity(const char *filename, uint lineno)
-{
- reg1 struct st_irem *irem;
- reg2 int flag=0;
- uint count=0;
-
- mysql_mutex_lock(&THR_LOCK_malloc);
-#ifndef PEDANTIC_SAFEMALLOC
- if (sf_malloc_tampered && (int) sf_malloc_count < 0)
- sf_malloc_count=0;
-#endif
- count=sf_malloc_count;
- for (irem= sf_malloc_root; irem != NULL && count-- ; irem= irem->next)
- flag+= _checkchunk (irem, filename, lineno);
- mysql_mutex_unlock(&THR_LOCK_malloc);
- if (count || irem)
- {
- const char *format="Error: Safemalloc link list destroyed, discovered at '%s:%d'";
- fprintf(stderr, format, filename, lineno); fputc('\n',stderr);
- fprintf(stderr, "root=%p,count=%d,irem=%p\n", sf_malloc_root,count,irem);
- (void) fflush(stderr);
- DBUG_PRINT("safe",(format, filename, lineno));
- flag=1;
- }
- return flag;
-} /* _sanity */
-
-
- /* malloc and copy */
-
-void *_my_memdup(const void *from, size_t length, const char *filename,
- uint lineno, myf MyFlags)
-{
- void *ptr;
- if ((ptr= _mymalloc(length,filename,lineno,MyFlags)) != 0)
- memcpy(ptr, from, length);
- return(ptr);
-} /*_my_memdup */
-
-
-char *_my_strdup(const char *from, const char *filename, uint lineno,
- myf MyFlags)
-{
- char *ptr;
- size_t length= strlen(from)+1;
- if ((ptr= (char*) _mymalloc(length,filename,lineno,MyFlags)) != 0)
- memcpy((uchar*) ptr, (uchar*) from, (size_t) length);
- return(ptr);
-} /* _my_strdup */
-
-
-char *_my_strndup(const char *from, size_t length,
- const char *filename, uint lineno,
- myf MyFlags)
-{
- char *ptr;
- if ((ptr= (char*) _mymalloc(length+1,filename,lineno,MyFlags)) != 0)
- {
- memcpy((uchar*) ptr, (uchar*) from, (size_t) length);
- ptr[length]=0;
- }
- return(ptr);
-}
diff --git a/mysys/string.c b/mysys/string.c
index 10a72b8a295..b1eded0664c 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -177,9 +177,6 @@ my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...)
void dynstr_free(DYNAMIC_STRING *str)
{
- if (str->str)
- {
- my_free(str->str,MYF(MY_WME));
- str->str=0;
- }
+ my_free(str->str);
+ str->str= NULL;
}
diff --git a/mysys/test_charset.c b/mysys/test_charset.c
index d867b49304e..5b399071d11 100644
--- a/mysys/test_charset.c
+++ b/mysys/test_charset.c
@@ -80,11 +80,11 @@ int main(int argc, char **argv) {
#ifdef NOT_USED_ANYMORE
cs_list = list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG));
printf("LIST OF CHARSETS (compiled + *.conf):\n%s\n", cs_list);
- my_free(cs_list,MYF(0));
+ my_free(cs_list);
cs_list = list_charsets(MYF(MY_CS_INDEX | MY_CS_LOADED));
printf("LIST OF CHARSETS (index + loaded):\n%s\n", cs_list);
- my_free(cs_list,MYF(0));
+ my_free(cs_list);
#endif
return 0;
diff --git a/mysys/testhash.c b/mysys/testhash.c
index 2add2ebd2d7..376303f29be 100644
--- a/mysys/testhash.c
+++ b/mysys/testhash.c
@@ -286,5 +286,5 @@ static int rnd(int max_value)
void free_record(void *record)
{
- my_free(record,MYF(0));
+ my_free(record);
}
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 8ee89cfb55d..555ac1cf990 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -262,7 +262,7 @@ void thr_end_alarm(thr_alarm_t *alarmed)
{
queue_remove(&alarm_queue,i),MYF(0);
if (alarm_data->malloced)
- my_free((uchar*) alarm_data,MYF(0));
+ my_free(alarm_data);
found++;
#ifdef DBUG_OFF
break;
diff --git a/mysys/tree.c b/mysys/tree.c
index ef33f75b7c6..8ea7102ed4c 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -183,7 +183,7 @@ static void delete_tree_element(TREE *tree, TREE_ELEMENT *element)
(*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
delete_tree_element(tree,element->right);
if (tree->with_delete)
- my_free((char*) element,MYF(0));
+ my_free(element);
}
}
@@ -326,7 +326,7 @@ int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg)
if (tree->free)
(*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
tree->allocated-= sizeof(TREE_ELEMENT) + tree->size_of_element + key_size;
- my_free((uchar*) element,MYF(0));
+ my_free(element);
tree->elements_in_tree--;
return 0;
}
diff --git a/mysys/trie.c b/mysys/trie.c
index 5738b9b866b..b2e93fcceac 100644
--- a/mysys/trie.c
+++ b/mysys/trie.c
@@ -211,7 +211,7 @@ my_bool ac_trie_prepare (TRIE *trie)
fail= fail->fail;
}
}
- my_free((uchar*)tmp_nodes, MYF(0));
+ my_free(tmp_nodes);
DBUG_RETURN(FALSE);
}
diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc
index 43138f0655f..9bdacdfeae9 100644
--- a/plugin/daemon_example/daemon_example.cc
+++ b/plugin/daemon_example/daemon_example.cc
@@ -175,7 +175,7 @@ static int daemon_example_plugin_deinit(void *p)
my_write(con->heartbeat_file, (uchar*) buffer, strlen(buffer), MYF(0));
my_close(con->heartbeat_file, MYF(0));
- my_free((char *)con, MYF(0));
+ my_free(con);
DBUG_RETURN(0);
}
diff --git a/plugin/semisync/semisync_master.h b/plugin/semisync/semisync_master.h
index 1a562e8bb77..dfadf85f271 100644
--- a/plugin/semisync/semisync_master.h
+++ b/plugin/semisync/semisync_master.h
@@ -255,7 +255,7 @@ private:
*/
void free_block(Block *block)
{
- my_free(block, MYF(0));
+ my_free(block);
--block_num;
}
diff --git a/scripts/mysql_config.pl.in b/scripts/mysql_config.pl.in
index 415c0d3040e..58482691213 100644
--- a/scripts/mysql_config.pl.in
+++ b/scripts/mysql_config.pl.in
@@ -42,8 +42,7 @@ use Cwd;
use strict;
my @exclude_cflags =
- qw/DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX
- DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS
+ qw/DDBUG_OFF DSAFE_MUTEX DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS
DEXTRA_DEBUG DHAVE_purify O O[0-9] xO[0-9] W[-A-Za-z]*
Xa xstrconst xc99=none
unroll2 ip mp restrict/;
diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh
index d2699726a25..0840a99e6e2 100644
--- a/scripts/mysql_config.sh
+++ b/scripts/mysql_config.sh
@@ -127,8 +127,7 @@ include="-I$pkgincludedir"
# and -xstrconst to make --cflags usable for Sun Forte C++
# FIXME until we have a --cxxflags, we need to remove -AC99
# to make --cflags usable for HP C++ (aCC)
-for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
- DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
+for remove in DDBUG_OFF DSAFE_MUTEX DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
Xa xstrconst "xc99=none" AC99 \
diff --git a/sql-common/client.c b/sql-common/client.c
index bb7bd4d2633..c277b153109 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -688,8 +688,7 @@ err2:
CloseHandle(handle_file_map);
}
err:
- if (tmp)
- my_free(tmp, MYF(0));
+ my_free(tmp);
if (error_allow)
error_code = GetLastError();
if (event_connect_request)
@@ -802,7 +801,7 @@ void free_rows(MYSQL_DATA *cur)
if (cur)
{
free_root(&cur->alloc,MYF(0));
- my_free((uchar*) cur,MYF(0));
+ my_free(cur);
}
}
@@ -1127,9 +1126,8 @@ mysql_free_result(MYSQL_RES *result)
free_rows(result->data);
if (result->fields)
free_root(&result->field_alloc,MYF(0));
- if (result->row)
- my_free((uchar*) result->row,MYF(0));
- my_free((uchar*) result,MYF(0));
+ my_free(result->row);
+ my_free(result);
}
DBUG_VOID_RETURN;
}
@@ -1167,13 +1165,13 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
{
options->init_commands= (DYNAMIC_ARRAY*)my_malloc(sizeof(DYNAMIC_ARRAY),
MYF(MY_WME));
- init_dynamic_array(options->init_commands,sizeof(char*),0,5 CALLER_INFO);
+ init_dynamic_array(options->init_commands,sizeof(char*),0,5);
}
if (!(tmp= my_strdup(cmd,MYF(MY_WME))) ||
insert_dynamic(options->init_commands, (uchar*)&tmp))
{
- my_free(tmp, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(tmp);
return 1;
}
@@ -1221,7 +1219,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
case 2: /* socket */
if (opt_arg)
{
- my_free(options->unix_socket,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->unix_socket);
options->unix_socket=my_strdup(opt_arg,MYF(MY_WME));
}
break;
@@ -1232,7 +1230,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
case 4: /* password */
if (opt_arg)
{
- my_free(options->password,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->password);
options->password=my_strdup(opt_arg,MYF(MY_WME));
}
break;
@@ -1246,7 +1244,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
case 7: /* user */
if (opt_arg)
{
- my_free(options->user,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->user);
options->user=my_strdup(opt_arg,MYF(MY_WME));
}
break;
@@ -1256,14 +1254,14 @@ void mysql_read_default_options(struct st_mysql_options *options,
case 9: /* host */
if (opt_arg)
{
- my_free(options->host,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->host);
options->host=my_strdup(opt_arg,MYF(MY_WME));
}
break;
case 10: /* database */
if (opt_arg)
{
- my_free(options->db,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->db);
options->db=my_strdup(opt_arg,MYF(MY_WME));
}
break;
@@ -1277,23 +1275,23 @@ void mysql_read_default_options(struct st_mysql_options *options,
break;
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
case 13: /* ssl_key */
- my_free(options->ssl_key, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->ssl_key);
options->ssl_key = my_strdup(opt_arg, MYF(MY_WME));
break;
case 14: /* ssl_cert */
- my_free(options->ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->ssl_cert);
options->ssl_cert = my_strdup(opt_arg, MYF(MY_WME));
break;
case 15: /* ssl_ca */
- my_free(options->ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->ssl_ca);
options->ssl_ca = my_strdup(opt_arg, MYF(MY_WME));
break;
case 16: /* ssl_capath */
- my_free(options->ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->ssl_capath);
options->ssl_capath = my_strdup(opt_arg, MYF(MY_WME));
break;
case 23: /* ssl_cipher */
- my_free(options->ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->ssl_cipher);
options->ssl_cipher= my_strdup(opt_arg, MYF(MY_WME));
break;
#else
@@ -1305,11 +1303,11 @@ void mysql_read_default_options(struct st_mysql_options *options,
break;
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
case 17: /* charset-lib */
- my_free(options->charset_dir,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->charset_dir);
options->charset_dir = my_strdup(opt_arg, MYF(MY_WME));
break;
case 18:
- my_free(options->charset_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->charset_name);
options->charset_name = my_strdup(opt_arg, MYF(MY_WME));
break;
case 19: /* Interactive-timeout */
@@ -1339,7 +1337,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
case 26: /* shared_memory_base_name */
#ifdef HAVE_SMEM
if (options->shared_memory_base_name != def_shared_memory_base_name)
- my_free(options->shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(options->shared_memory_base_name);
options->shared_memory_base_name=my_strdup(opt_arg,MYF(MY_WME));
#endif
break;
@@ -1760,14 +1758,14 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
struct st_VioSSLFd *ssl_fd= (struct st_VioSSLFd*) mysql->connector_fd;
DBUG_ENTER("mysql_ssl_free");
- my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.ssl_key);
+ my_free(mysql->options.ssl_cert);
+ my_free(mysql->options.ssl_ca);
+ my_free(mysql->options.ssl_capath);
+ my_free(mysql->options.ssl_cipher);
if (ssl_fd)
SSL_CTX_free(ssl_fd->ssl_context);
- my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->connector_fd);
mysql->options.ssl_key = 0;
mysql->options.ssl_cert = 0;
mysql->options.ssl_ca = 0;
@@ -2271,8 +2269,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
(mysql->options.my_cnf_file ?
mysql->options.my_cnf_file : "my"),
mysql->options.my_cnf_group);
- my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.my_cnf_file);
+ my_free(mysql->options.my_cnf_group);
mysql->options.my_cnf_file=mysql->options.my_cnf_group=0;
}
@@ -3014,7 +3012,7 @@ mysql_select_db(MYSQL *mysql, const char *db)
if ((error=simple_command(mysql,COM_INIT_DB, (const uchar*) db,
(ulong) strlen(db),0)))
DBUG_RETURN(error);
- my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->db);
mysql->db=my_strdup(db,MYF(MY_WME));
DBUG_RETURN(0);
}
@@ -3029,32 +3027,32 @@ static void mysql_close_free_options(MYSQL *mysql)
{
DBUG_ENTER("mysql_close_free_options");
- my_free(mysql->options.user,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.host,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.password,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.unix_socket,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.db,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.client_ip,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.user);
+ my_free(mysql->options.host);
+ my_free(mysql->options.password);
+ my_free(mysql->options.unix_socket);
+ my_free(mysql->options.db);
+ my_free(mysql->options.my_cnf_file);
+ my_free(mysql->options.my_cnf_group);
+ my_free(mysql->options.charset_dir);
+ my_free(mysql->options.charset_name);
+ my_free(mysql->options.client_ip);
if (mysql->options.init_commands)
{
DYNAMIC_ARRAY *init_commands= mysql->options.init_commands;
char **ptr= (char**)init_commands->buffer;
char **end= ptr + init_commands->elements;
for (; ptr<end; ptr++)
- my_free(*ptr,MYF(MY_WME));
+ my_free(*ptr);
delete_dynamic(init_commands);
- my_free((char*)init_commands,MYF(MY_WME));
+ my_free(init_commands);
}
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
mysql_ssl_free(mysql);
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
#ifdef HAVE_SMEM
if (mysql->options.shared_memory_base_name != def_shared_memory_base_name)
- my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.shared_memory_base_name);
#endif /* HAVE_SMEM */
bzero((char*) &mysql->options,sizeof(mysql->options));
DBUG_VOID_RETURN;
@@ -3063,12 +3061,12 @@ static void mysql_close_free_options(MYSQL *mysql)
static void mysql_close_free(MYSQL *mysql)
{
- my_free((uchar*) mysql->host_info,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->host_info);
+ my_free(mysql->user);
+ my_free(mysql->passwd);
+ my_free(mysql->db);
#if defined(EMBEDDED_LIBRARY) || MYSQL_VERSION_ID >= 50100
- my_free(mysql->info_buffer,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->info_buffer);
mysql->info_buffer= 0;
#endif
/* Clear pointers for better safety */
@@ -3176,7 +3174,7 @@ void STDCALL mysql_close(MYSQL *mysql)
(*mysql->methods->free_embedded_thd)(mysql);
#endif
if (mysql->free_me)
- my_free((uchar*) mysql,MYF(0));
+ my_free(mysql);
}
DBUG_VOID_RETURN;
}
@@ -3313,7 +3311,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql)
if (!(result->data=
(*mysql->methods->read_rows)(mysql,mysql->fields,mysql->field_count)))
{
- my_free((uchar*) result,MYF(0));
+ my_free(result);
DBUG_RETURN(0);
}
mysql->affected_rows= result->row_count= result->data->rows;
@@ -3361,7 +3359,7 @@ static MYSQL_RES * cli_use_result(MYSQL *mysql)
if (!(result->row=(MYSQL_ROW)
my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME))))
{ /* Ptrs: to one row */
- my_free((uchar*) result,MYF(0));
+ my_free(result);
DBUG_RETURN(0);
}
result->fields= mysql->fields;
@@ -3482,19 +3480,19 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
add_init_command(&mysql->options,arg);
break;
case MYSQL_READ_DEFAULT_FILE:
- my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.my_cnf_file);
mysql->options.my_cnf_file=my_strdup(arg,MYF(MY_WME));
break;
case MYSQL_READ_DEFAULT_GROUP:
- my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.my_cnf_group);
mysql->options.my_cnf_group=my_strdup(arg,MYF(MY_WME));
break;
case MYSQL_SET_CHARSET_DIR:
- my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.charset_dir);
mysql->options.charset_dir=my_strdup(arg,MYF(MY_WME));
break;
case MYSQL_SET_CHARSET_NAME:
- my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.charset_name);
mysql->options.charset_name=my_strdup(arg,MYF(MY_WME));
break;
case MYSQL_OPT_PROTOCOL:
@@ -3503,7 +3501,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
case MYSQL_SHARED_MEMORY_BASE_NAME:
#ifdef HAVE_SMEM
if (mysql->options.shared_memory_base_name != def_shared_memory_base_name)
- my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.shared_memory_base_name);
mysql->options.shared_memory_base_name=my_strdup(arg,MYF(MY_WME));
#endif
break;
diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc
index dde6267331f..74e5b2c70f3 100644
--- a/sql/debug_sync.cc
+++ b/sql/debug_sync.cc
@@ -626,7 +626,7 @@ void debug_sync_end_thread(THD *thd)
action->wait_for.free();
action->sync_point.free();
}
- my_free(ds_control->ds_action, MYF(0));
+ my_free(ds_control->ds_action);
}
/* Statistics. */
@@ -637,7 +637,7 @@ void debug_sync_end_thread(THD *thd)
debug_sync_global.dsp_max_active= ds_control->dsp_max_active;
mysql_mutex_unlock(&debug_sync_global.ds_mutex);
- my_free(ds_control, MYF(0));
+ my_free(ds_control);
thd->debug_sync_control= NULL;
}
diff --git a/sql/derror.cc b/sql/derror.cc
index 7f1435e89c1..bf8c589a65f 100644
--- a/sql/derror.cc
+++ b/sql/derror.cc
@@ -79,7 +79,7 @@ bool init_errmessage(void)
/* Register messages for use with my_error(). */
if (my_error_register(get_server_errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST))
{
- x_free((uchar*) errmsgs);
+ my_free(errmsgs);
DBUG_RETURN(TRUE);
}
@@ -155,7 +155,8 @@ Check that the above file is the right version for this program!",
DBUG_RETURN(1);
}
- x_free((uchar*) *point); /* Free old language */
+ /* Free old language */
+ my_free(*point);
if (!(*point= (const char**)
my_malloc((size_t) (length+count*sizeof(char*)),MYF(0))))
{
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index c778d72a016..dd1845b29bc 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -176,7 +176,7 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n)
return TRUE;
if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME))))
{
- my_free((uchar*) dbname.str, MYF(0));
+ my_free(dbname.str);
return TRUE;
}
return FALSE;
@@ -192,8 +192,8 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n)
Event_queue_element_for_exec::~Event_queue_element_for_exec()
{
- my_free((uchar*) dbname.str, MYF(0));
- my_free((uchar*) name.str, MYF(0));
+ my_free(dbname.str);
+ my_free(name.str);
}
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index c646642dbba..aa4d376d86e 100755
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -238,7 +238,7 @@ event_scheduler_thread(void *arg)
res= post_init_event_thread(thd);
DBUG_ENTER("event_scheduler_thread");
- my_free((char*)arg, MYF(0));
+ my_free(arg);
if (!res)
scheduler->run(thd);
diff --git a/sql/examples/CMakeLists.txt b/sql/examples/CMakeLists.txt
index 1a22e9a3efd..3c5cc23ec3b 100755
--- a/sql/examples/CMakeLists.txt
+++ b/sql/examples/CMakeLists.txt
@@ -13,8 +13,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFE_MUTEX")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFE_MUTEX")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/extra/yassl/include
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 3f3dc4e1e3e..af9387c3129 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -264,7 +264,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
{
if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
{
- x_free(table_sort.buffpek);
+ my_free(table_sort.buffpek);
table_sort.buffpek= 0;
}
if (!(table_sort.buffpek=
@@ -304,13 +304,12 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
error =0;
err:
- if (param.tmp_buffer)
- x_free(param.tmp_buffer);
+ my_free(param.tmp_buffer);
if (!subselect || !subselect->is_uncacheable())
{
- x_free((uchar*) sort_keys);
+ my_free(sort_keys);
table_sort.sort_keys= 0;
- x_free((uchar*) buffpek);
+ my_free(buffpek);
table_sort.buffpek= 0;
table_sort.buffpek_len= 0;
}
@@ -347,32 +346,22 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
void filesort_free_buffers(TABLE *table, bool full)
{
- if (table->sort.record_pointers)
- {
- my_free((uchar*) table->sort.record_pointers,MYF(0));
- table->sort.record_pointers=0;
- }
+ my_free(table->sort.record_pointers);
+ table->sort.record_pointers= NULL;
+
if (full)
{
- if (table->sort.sort_keys )
- {
- x_free((uchar*) table->sort.sort_keys);
- table->sort.sort_keys= 0;
- }
- if (table->sort.buffpek)
- {
- x_free((uchar*) table->sort.buffpek);
- table->sort.buffpek= 0;
- table->sort.buffpek_len= 0;
- }
- }
- if (table->sort.addon_buf)
- {
- my_free((char *) table->sort.addon_buf, MYF(0));
- my_free((char *) table->sort.addon_field, MYF(MY_ALLOW_ZERO_PTR));
- table->sort.addon_buf=0;
- table->sort.addon_field=0;
+ my_free(table->sort.sort_keys);
+ table->sort.sort_keys= NULL;
+ my_free(table->sort.buffpek);
+ table->sort.buffpek= NULL;
+ table->sort.buffpek_len= NULL;
}
+
+ my_free(table->sort.addon_buf);
+ my_free(table->sort.addon_field);
+ table->sort.addon_buf= NULL;
+ table->sort.addon_field= NULL;
}
/** Make a array of string pointers. */
@@ -413,7 +402,7 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count,
if (reinit_io_cache(buffpek_pointers,READ_CACHE,0L,0,0) ||
my_b_read(buffpek_pointers, (uchar*) tmp, length))
{
- my_free((char*) tmp, MYF(0));
+ my_free(tmp);
tmp=0;
}
}
diff --git a/sql/gstream.h b/sql/gstream.h
index 65acc2ff193..6bb3c9bac10 100644
--- a/sql/gstream.h
+++ b/sql/gstream.h
@@ -45,7 +45,7 @@ public:
{}
~Gis_read_stream()
{
- my_free((uchar*) m_err_msg, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_err_msg);
}
enum enum_tok_types get_next_toc_type();
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 68b98c79a50..ecf2984a4c0 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -1035,7 +1035,7 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array,
}
if (loop == 0 && offset > buffer_size)
{
- my_free(buffer, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buffer);
buffer_size= 0;
DBUG_PRINT("info", ("allocate blobs buffer size %u", offset));
buffer= (uchar*) my_malloc(offset, MYF(MY_WME));
@@ -1188,8 +1188,8 @@ int ha_ndbcluster::get_metadata(const char *path)
if (readfrm(path, &data, &length) ||
packfrm(data, length, &pack_data, &pack_length))
{
- my_free(data, MYF(MY_ALLOW_ZERO_PTR));
- my_free(pack_data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(data);
+ my_free(pack_data);
DBUG_RETURN(1);
}
@@ -1208,8 +1208,8 @@ int ha_ndbcluster::get_metadata(const char *path)
DBUG_DUMP("frm", (uchar*) tab->getFrmData(), tab->getFrmLength());
error= HA_ERR_TABLE_DEF_CHANGED;
}
- my_free((char*)data, MYF(0));
- my_free((char*)pack_data, MYF(0));
+ my_free(data);
+ my_free(pack_data);
if (error)
goto err;
@@ -1235,7 +1235,7 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
unsigned sz= index->getNoOfIndexColumns();
if (data.unique_index_attrid_map)
- my_free((char*)data.unique_index_attrid_map, MYF(0));
+ my_free(data.unique_index_attrid_map);
data.unique_index_attrid_map= (uchar*)my_malloc(sz,MYF(MY_WME));
if (data.unique_index_attrid_map == 0)
{
@@ -1313,7 +1313,7 @@ static void ndb_clear_index(NDB_INDEX_DATA &data)
{
if (data.unique_index_attrid_map)
{
- my_free((char*)data.unique_index_attrid_map, MYF(0));
+ my_free(data.unique_index_attrid_map);
}
if (data.index_stat)
{
@@ -5399,15 +5399,15 @@ int ha_ndbcluster::create(const char *name,
DBUG_RETURN(1);
if (packfrm(data, length, &pack_data, &pack_length))
{
- my_free((char*)data, MYF(0));
+ my_free(data);
DBUG_RETURN(2);
}
DBUG_PRINT("info",
("setFrm data: 0x%lx len: %lu", (long) pack_data,
(ulong) pack_length));
tab.setFrm(pack_data, pack_length);
- my_free((char*)data, MYF(0));
- my_free((char*)pack_data, MYF(0));
+ my_free(data);
+ my_free(pack_data);
/*
Check for disk options
@@ -5751,8 +5751,8 @@ int ha_ndbcluster::create_handler_files(const char *file,
packfrm(data, length, &pack_data, &pack_length))
{
DBUG_PRINT("info", ("Missing frm for %s", m_tabname));
- my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(data);
+ my_free(pack_data);
error= 1;
}
else
@@ -5766,8 +5766,8 @@ int ha_ndbcluster::create_handler_files(const char *file,
set_ndb_err(current_thd, dict->getNdbError());
error= ndb_to_mysql_error(&dict->getNdbError());
}
- my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(data);
+ my_free(pack_data);
}
set_ndb_share_state(m_share, NSS_INITIAL);
@@ -6565,7 +6565,7 @@ ha_ndbcluster::~ha_ndbcluster()
free_share(&m_share);
}
release_metadata(thd, ndb);
- my_free(m_blobs_buffer, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_blobs_buffer);
m_blobs_buffer= 0;
// Check for open cursor/transaction
@@ -6911,7 +6911,7 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db,
DBUG_RETURN(0);
err:
- my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(data);
if (share)
{
/* ndb_share reference temporary free */
@@ -7177,8 +7177,8 @@ int ndbcluster_find_all_files(THD *thd)
free_share(&share);
}
}
- my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*) pack_data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(data);
+ my_free(pack_data);
mysql_mutex_lock(&LOCK_open);
if (discover)
@@ -8681,7 +8681,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
if (my_hash_insert(&ndbcluster_open_tables, (uchar*) share))
{
free_root(&share->mem_root, MYF(0));
- my_free((uchar*) share, 0);
+ my_free(share);
*root_ptr= old_root;
if (!have_lock)
mysql_mutex_unlock(&ndbcluster_mutex);
@@ -8752,7 +8752,7 @@ void ndbcluster_real_free_share(NDB_SHARE **share)
}
#endif
free_root(&(*share)->mem_root, MYF(0));
- my_free((uchar*) *share, MYF(0));
+ my_free(*share);
*share= 0;
dbug_print_open_tables();
@@ -10076,7 +10076,7 @@ int ha_ndbcluster::set_range_data(void *tab_ref, partition_info *part_info)
}
tab->setRangeListData(range_data, sizeof(int32)*part_info->num_parts);
error:
- my_free((char*)range_data, MYF(0));
+ my_free(range_data);
DBUG_RETURN(error);
}
@@ -10113,7 +10113,7 @@ int ha_ndbcluster::set_list_data(void *tab_ref, partition_info *part_info)
}
tab->setRangeListData(list_data, 2*sizeof(int32)*part_info->num_list_values);
error:
- my_free((char*)list_data, MYF(0));
+ my_free(list_data);
DBUG_RETURN(error);
}
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc
index ab046164485..4f8bb66fcb0 100644
--- a/sql/ha_ndbcluster_binlog.cc
+++ b/sql/ha_ndbcluster_binlog.cc
@@ -1020,7 +1020,7 @@ static void ndbcluster_get_schema(NDB_SHARE *share,
ptrdiff);
if (ret != 0)
{
- my_free(blobs_buffer, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(blobs_buffer);
DBUG_PRINT("info", ("blob read error"));
DBUG_ASSERT(FALSE);
}
@@ -1071,7 +1071,7 @@ static void ndbcluster_get_schema(NDB_SHARE *share,
field++;
s->type= ((Field_long *)*field)->val_int();
/* free blobs buffer */
- my_free(blobs_buffer, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(blobs_buffer);
dbug_tmp_restore_column_map(table->read_set, old_map);
}
@@ -1739,7 +1739,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
old->getObjectVersion() != altered_table->getObjectVersion())
dict->putTable(altered_table);
- my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(data);
data= NULL;
if ((error= unpackfrm(&data, &length,
(const uchar*) altered_table->getFrmData())) ||
@@ -1772,8 +1772,8 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
mysql_mutex_unlock(&LOCK_open);
}
- my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(data);
+ my_free(pack_data);
}
// If only frm was changed continue replicating
@@ -3507,8 +3507,8 @@ ndb_binlog_thread_handle_data_event(Ndb *ndb, NdbEventOperation *pOp,
if (share->flags & NSF_BLOB_FLAG)
{
- my_free(blobs_buffer[0], MYF(MY_ALLOW_ZERO_PTR));
- my_free(blobs_buffer[1], MYF(MY_ALLOW_ZERO_PTR));
+ my_free(blobs_buffer[0]);
+ my_free(blobs_buffer[1]);
}
return 0;
@@ -3580,7 +3580,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key,
ndb_schema_object->key_length= length;
if (my_hash_insert(&ndb_schema_objects, (uchar*) ndb_schema_object))
{
- my_free((uchar*) ndb_schema_object, 0);
+ my_free(ndb_schema_object);
break;
}
mysql_mutex_init(key_ndb_schema_object_mutex, &ndb_schema_object->mutex, MY_MUTEX_INIT_FAST);
@@ -3612,7 +3612,7 @@ static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object,
DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
my_hash_delete(&ndb_schema_objects, (uchar*) *ndb_schema_object);
mysql_mutex_destroy(&(*ndb_schema_object)->mutex);
- my_free((uchar*) *ndb_schema_object, MYF(0));
+ my_free(*ndb_schema_object);
*ndb_schema_object= 0;
}
else
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 3fb5a30b560..90a4802082b 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -287,7 +287,7 @@ ha_partition::~ha_partition()
for (i= 0; i < m_tot_parts; i++)
delete m_file[i];
}
- my_free((char*) m_ordered_rec_buffer, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_ordered_rec_buffer);
clear_handler_file();
DBUG_VOID_RETURN;
@@ -2267,7 +2267,7 @@ bool ha_partition::create_handler_file(const char *name)
}
else
result= TRUE;
- my_free((char*) file_buffer, MYF(0));
+ my_free(file_buffer);
DBUG_RETURN(result);
}
@@ -2285,8 +2285,8 @@ void ha_partition::clear_handler_file()
{
if (m_engine_array)
plugin_unlock_list(NULL, m_engine_array, m_tot_parts);
- my_free((char*) m_file_buffer, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*) m_engine_array, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_file_buffer);
+ my_free(m_engine_array);
m_file_buffer= NULL;
m_engine_array= NULL;
}
@@ -2495,7 +2495,7 @@ bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root)
err3:
my_afree((gptr) engine_array);
err2:
- my_free(file_buffer, MYF(0));
+ my_free(file_buffer);
err1:
(void) mysql_file_close(file, MYF(0));
DBUG_RETURN(TRUE);
diff --git a/sql/handler.cc b/sql/handler.cc
index 587490dd708..b42840c7b1b 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -392,7 +392,7 @@ static int ha_finish_errors(void)
/* Allocate a pointer array for the error message strings. */
if (! (errmsgs= my_error_unregister(HA_ERR_FIRST, HA_ERR_LAST)))
return 1;
- my_free((uchar*) errmsgs, MYF(0));
+ my_free(errmsgs);
return 0;
}
@@ -447,7 +447,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
hton2plugin[hton->slot]= NULL;
}
- my_free((uchar*)hton, MYF(0));
+ my_free(hton);
end:
DBUG_RETURN(0);
@@ -580,7 +580,7 @@ err_deinit:
(void) plugin->plugin->deinit(NULL);
err:
- my_free((uchar*) hton, MYF(0));
+ my_free(hton);
err_no_hton_memory:
plugin->data= NULL;
DBUG_RETURN(1);
@@ -1630,7 +1630,7 @@ int ha_recover(HASH *commit_list)
plugin_foreach(NULL, xarecover_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &info);
- my_free((uchar*)info.list, MYF(0));
+ my_free(info.list);
if (info.found_foreign_xids)
sql_print_warning("Found %d prepared XA transactions",
info.found_foreign_xids);
@@ -3658,7 +3658,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name)
build_table_filename(path, sizeof(path) - 1, db, name, "", 0);
// Save the frm file
error= writefrm(path, frmblob, frmlen);
- my_free(frmblob, MYF(0));
+ my_free(frmblob);
if (error)
DBUG_RETURN(2);
@@ -4865,7 +4865,7 @@ int fl_log_iterator_next(struct handler_iterator *iterator,
void fl_log_iterator_destroy(struct handler_iterator *iterator)
{
- my_free((uchar*)iterator->buffer, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(iterator->buffer);
}
diff --git a/sql/handler.h b/sql/handler.h
index fc49d9e647d..5e08ed23bef 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -458,11 +458,7 @@ typedef struct xid_t XID;
/* for recover() handlerton call */
#define MIN_XID_LIST_SIZE 128
-#ifdef SAFEMALLOC
-#define MAX_XID_LIST_SIZE 256
-#else
#define MAX_XID_LIST_SIZE (1024*128)
-#endif
/*
These structures are used to pass information from a set of SQL commands
diff --git a/sql/item_func.cc b/sql/item_func.cc
index efa14c8498b..2d5848e314e 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3560,7 +3560,7 @@ public:
{
if (my_hash_insert(&hash_user_locks,(uchar*) this))
{
- my_free(key,MYF(0));
+ my_free(key);
key=0;
}
}
@@ -3570,7 +3570,7 @@ public:
if (key)
{
my_hash_delete(&hash_user_locks,(uchar*) this);
- my_free(key, MYF(0));
+ my_free(key);
}
mysql_cond_destroy(&cond);
}
@@ -4079,7 +4079,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
memcpy(entry->name.str, name.str, name.length+1);
if (my_hash_insert(hash,(uchar*) entry))
{
- my_free((char*) entry,MYF(0));
+ my_free(entry);
return 0;
}
}
@@ -4217,7 +4217,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
{
char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry));
if (entry->value && entry->value != pos)
- my_free(entry->value,MYF(0));
+ my_free(entry->value);
entry->value= 0;
entry->length= 0;
}
@@ -4232,7 +4232,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
if (entry->value != pos)
{
if (entry->value)
- my_free(entry->value,MYF(0));
+ my_free(entry->value);
entry->value=pos;
}
}
diff --git a/sql/keycaches.cc b/sql/keycaches.cc
index d68e2bccd96..14551803cfc 100644
--- a/sql/keycaches.cc
+++ b/sql/keycaches.cc
@@ -44,7 +44,7 @@ public:
}
~NAMED_ILINK()
{
- my_free((uchar*) name, MYF(0));
+ my_free((void *) name);
}
};
@@ -104,7 +104,7 @@ KEY_CACHE *create_key_cache(const char *name, uint length)
{
if (!new NAMED_ILINK(&key_caches, name, length, (uchar*) key_cache))
{
- my_free((char*) key_cache, MYF(0));
+ my_free(key_cache);
key_cache= 0;
}
else
@@ -140,7 +140,7 @@ KEY_CACHE *get_or_create_key_cache(const char *name, uint length)
void free_key_cache(const char *name, KEY_CACHE *key_cache)
{
end_key_cache(key_cache, 1); // Can never fail
- my_free((char*) key_cache, MYF(0));
+ my_free(key_cache);
}
diff --git a/sql/lock.cc b/sql/lock.cc
index 52d97a2422b..0743120ec6b 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -262,7 +262,7 @@ static void reset_lock_data(MYSQL_LOCK *sql_lock)
static void reset_lock_data_and_free(MYSQL_LOCK **mysql_lock)
{
reset_lock_data(*mysql_lock);
- my_free(*mysql_lock, MYF(0));
+ my_free(*mysql_lock);
*mysql_lock= 0;
}
@@ -384,7 +384,7 @@ void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock)
thr_multi_unlock(sql_lock->locks,sql_lock->lock_count);
if (sql_lock->table_count)
(void) unlock_external(thd,sql_lock->table,sql_lock->table_count);
- my_free((uchar*) sql_lock,MYF(0));
+ my_free(sql_lock);
DBUG_VOID_RETURN;
}
@@ -545,7 +545,7 @@ void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock)
{
for (uint i=0; i < locked->lock_count; i++)
thr_abort_locks(locked->locks[i]->lock, upgrade_lock);
- my_free((uchar*) locked,MYF(0));
+ my_free(locked);
}
DBUG_VOID_RETURN;
}
@@ -577,7 +577,7 @@ bool mysql_lock_abort_for_thread(THD *thd, TABLE *table)
table->in_use->thread_id))
result= TRUE;
}
- my_free((uchar*) locked,MYF(0));
+ my_free(locked);
}
DBUG_RETURN(result);
}
@@ -619,8 +619,8 @@ MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b)
}
/* Delete old, not needed locks */
- my_free((uchar*) a,MYF(0));
- my_free((uchar*) b,MYF(0));
+ my_free(a);
+ my_free(b);
thr_lock_merge_status(sql_lock->locks, sql_lock->lock_count);
DBUG_RETURN(sql_lock);
diff --git a/sql/log.cc b/sql/log.cc
index 0ac61513d22..521cedffc81 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1501,7 +1501,7 @@ static int binlog_close_connection(handlerton *hton, THD *thd)
DBUG_ASSERT(cache_mngr->trx_cache.empty() && cache_mngr->stmt_cache.empty());
thd_set_ha_data(thd, binlog_hton, NULL);
cache_mngr->~binlog_cache_mngr();
- my_free((uchar*)cache_mngr, MYF(0));
+ my_free(cache_mngr);
return 0;
}
@@ -2245,7 +2245,8 @@ shutdown the MySQL server and restart it.", name, errno);
if (file >= 0)
mysql_file_close(file, MYF(0));
end_io_cache(&log_file);
- safeFree(name);
+ my_free(name);
+ name= NULL;
log_state= LOG_CLOSED;
DBUG_RETURN(1);
}
@@ -2306,7 +2307,8 @@ void MYSQL_LOG::close(uint exiting)
}
log_state= (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED;
- safeFree(name);
+ my_free(name);
+ name= NULL;
DBUG_VOID_RETURN;
}
@@ -2384,7 +2386,7 @@ void MYSQL_QUERY_LOG::reopen_file()
*/
open(save_name, log_type, 0, io_cache_type);
- my_free(save_name, MYF(0));
+ my_free(save_name);
mysql_mutex_unlock(&LOCK_log);
@@ -2985,7 +2987,8 @@ shutdown the MySQL server and restart it.", name, errno);
mysql_file_close(file, MYF(0));
end_io_cache(&log_file);
end_io_cache(&index_file);
- safeFree(name);
+ my_free(name);
+ name= NULL;
log_state= LOG_CLOSED;
DBUG_RETURN(1);
}
@@ -3318,7 +3321,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
need_start_event=1;
if (!open_index_file(index_file_name, 0, FALSE))
open(save_name, log_type, 0, io_cache_type, no_auto_events, max_size, 0, FALSE);
- my_free((uchar*) save_name, MYF(0));
+ my_free((void *) save_name);
err:
if (error == 1)
@@ -3456,7 +3459,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
DBUG_ASSERT(!included || rli->linfo.index_file_start_offset == 0);
err:
- my_free(to_purge_if_included, MYF(0));
+ my_free(to_purge_if_included);
mysql_mutex_unlock(&LOCK_index);
DBUG_RETURN(error);
}
@@ -4096,7 +4099,7 @@ void MYSQL_BIN_LOG::new_file_impl(bool need_lock)
if (!open_index_file(index_file_name, 0, FALSE))
open(old_name, log_type, new_name_ptr,
io_cache_type, no_auto_events, max_size, 1, FALSE);
- my_free(old_name,MYF(0));
+ my_free(old_name);
end:
if (need_lock)
@@ -4354,7 +4357,7 @@ int THD::binlog_setup_trx_data()
open_cached_file(&cache_mngr->trx_cache.cache_log, mysql_tmpdir,
LOG_PREFIX, binlog_cache_size, MYF(MY_WME)))
{
- my_free((uchar*)cache_mngr, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(cache_mngr);
DBUG_RETURN(1); // Didn't manage to set it up
}
thd_set_ha_data(this, binlog_hton, cache_mngr);
@@ -5361,7 +5364,8 @@ void MYSQL_BIN_LOG::close(uint exiting)
}
}
log_state= (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED;
- safeFree(name);
+ my_free(name);
+ name= NULL;
DBUG_VOID_RETURN;
}
@@ -6052,7 +6056,7 @@ void TC_LOG_MMAP::close()
mysql_cond_destroy(&pages[i].cond);
}
case 3:
- my_free((uchar*)pages, MYF(0));
+ my_free(pages);
case 2:
my_munmap((char*)data, (size_t)file_length);
case 1:
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 606f5945a07..52275a4b6bd 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1149,7 +1149,7 @@ err:
sql_print_error("Error in Log_event::read_log_event(): "
"'%s', data_len: %d, event_type: %d",
error,data_len,head[EVENT_TYPE_OFFSET]);
- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buf);
/*
The SQL slave thread will check if file->error<0 to know
if there was an I/O error. Even if there is no "low-level" I/O errors
@@ -2066,7 +2066,7 @@ void Log_event::print_base64(IO_CACHE* file,
}
}
- my_free(tmp_str, MYF(0));
+ my_free(tmp_str);
DBUG_VOID_RETURN;
}
@@ -2146,7 +2146,7 @@ void Query_log_event::pack_info(Protocol *protocol)
pos+= q_len;
}
protocol->store(buf, pos-buf, &my_charset_bin);
- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buf);
}
#endif
@@ -3965,7 +3965,7 @@ Format_description_log_event(const char* buf,
DBUG_PRINT("info", (" number_of_event_types=%d",
number_of_event_types));
/* this makes is_valid() return false. */
- my_free(post_header_len, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(post_header_len);
post_header_len= NULL;
DBUG_VOID_RETURN;
}
@@ -4288,7 +4288,7 @@ void Load_log_event::pack_info(Protocol *protocol)
return;
print_query(TRUE, NULL, buf, &end, 0, 0);
protocol->store(buf, end-buf, &my_charset_bin);
- my_free(buf, MYF(0));
+ my_free(buf);
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@@ -5557,7 +5557,7 @@ void User_var_log_event::pack_info(Protocol* protocol)
buf[2+name_len]= '`';
buf[3+name_len]= '=';
protocol->store(buf, event_len, &my_charset_bin);
- my_free(buf, MYF(0));
+ my_free(buf);
}
#endif /* !MYSQL_CLIENT */
@@ -5972,7 +5972,7 @@ Slave_log_event::Slave_log_event(THD* thd_arg,
Slave_log_event::~Slave_log_event()
{
- my_free(mem_pool, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mem_pool);
}
@@ -6794,7 +6794,7 @@ int Execute_load_log_event::do_apply_event(Relay_log_info const *rli)
{
rli->report(ERROR_LEVEL, rli->last_error().number,
"%s. Failed executing load from '%s'", tmp, fname);
- my_free(tmp,MYF(0));
+ my_free(tmp);
}
goto err;
}
@@ -6999,7 +6999,7 @@ void Execute_load_query_log_event::pack_info(Protocol *protocol)
pos= strmov(pos, " ;file_id=");
pos= int10_to_str((long) file_id, pos, 10);
protocol->store(buf, pos-buf, &my_charset_bin);
- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buf);
}
@@ -7015,7 +7015,7 @@ Execute_load_query_log_event::do_apply_event(Relay_log_info const *rli)
buf= (char*) my_malloc(q_len + 1 - (fn_pos_end - fn_pos_start) +
(FN_REFLEN + 10) + 10 + 8 + 5, MYF(MY_WME));
- DBUG_EXECUTE_IF("LOAD_DATA_INFILE_has_fatal_error", my_free(buf, MYF(0)); buf= NULL;);
+ DBUG_EXECUTE_IF("LOAD_DATA_INFILE_has_fatal_error", my_free(buf); buf= NULL;);
/* Replace filename and LOCAL keyword in query before executing it */
if (buf == NULL)
@@ -7058,7 +7058,7 @@ Execute_load_query_log_event::do_apply_event(Relay_log_info const *rli)
if (!error)
mysql_file_delete(key_file_log_event_data, fname, MYF(MY_WME));
- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buf);
return error;
}
#endif
@@ -7323,7 +7323,7 @@ Rows_log_event::~Rows_log_event()
if (m_cols.bitmap == m_bitbuf) // no my_malloc happened
m_cols.bitmap= 0; // so no my_free in bitmap_free
bitmap_free(&m_cols); // To pair with bitmap_init().
- my_free((uchar*)m_rows_buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_rows_buf);
}
int Rows_log_event::get_data_size()
@@ -8247,8 +8247,8 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
Table_map_log_event::~Table_map_log_event()
{
- my_free(m_meta_memory, MYF(MY_ALLOW_ZERO_PTR));
- my_free(m_memory, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_meta_memory);
+ my_free(m_memory);
}
/*
@@ -8298,7 +8298,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
(!rpl_filter->db_ok(table_list->db) ||
(rpl_filter->is_on() && !rpl_filter->tables_ok("", table_list))))
{
- my_free(memory, MYF(MY_WME));
+ my_free(memory);
}
else
{
@@ -9353,7 +9353,7 @@ Delete_rows_log_event::do_after_row_operations(const Slave_reporting_capability
{
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
m_table->file->ha_index_or_rnd_end();
- my_free(m_key, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_key);
m_key= NULL;
return error;
@@ -9476,7 +9476,7 @@ Update_rows_log_event::do_after_row_operations(const Slave_reporting_capability
{
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
m_table->file->ha_index_or_rnd_end();
- my_free(m_key, MYF(MY_ALLOW_ZERO_PTR)); // Free for multi_malloc
+ my_free(m_key); // Free for multi_malloc
m_key= NULL;
return error;
diff --git a/sql/log_event.h b/sql/log_event.h
index bd95c74b6c5..0119b11cc23 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -1031,7 +1031,7 @@ public:
static void operator delete(void *ptr, size_t size)
{
- my_free((uchar*) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
+ my_free(ptr);
}
/* Placement version of the above operators */
@@ -1088,7 +1088,7 @@ public:
{
if (temp_buf)
{
- my_free(temp_buf, MYF(0));
+ my_free(temp_buf);
temp_buf = 0;
}
}
@@ -1720,7 +1720,7 @@ public:
~Query_log_event()
{
if (data_buf)
- my_free((uchar*) data_buf, MYF(0));
+ my_free(data_buf);
}
Log_event_type get_type_code() { return QUERY_EVENT; }
#ifdef MYSQL_SERVER
@@ -2299,7 +2299,7 @@ public:
*description_event);
~Format_description_log_event()
{
- my_free((uchar*)post_header_len, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(post_header_len);
}
Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
#ifdef MYSQL_SERVER
@@ -2698,7 +2698,7 @@ public:
~Rotate_log_event()
{
if (flags & DUP_NAME)
- my_free((uchar*) new_log_ident, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((void*) new_log_ident);
}
Log_event_type get_type_code() { return ROTATE_EVENT;}
int get_data_size() { return ident_len + ROTATE_HEADER_LEN;}
@@ -2760,7 +2760,7 @@ public:
const Format_description_log_event* description_event);
~Create_file_log_event()
{
- my_free((char*) event_buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((void*) event_buf);
}
Log_event_type get_type_code()
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index d9b48cd134e..9263578e0b5 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1017,7 +1017,7 @@ int Delete_rows_log_event_old::do_after_row_operations(TABLE *table, int error)
{
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
table->file->ha_index_or_rnd_end();
- my_free(m_memory, MYF(MY_ALLOW_ZERO_PTR)); // Free for multi_malloc
+ my_free(m_memory); // Free for multi_malloc
m_memory= NULL;
m_after_image= NULL;
m_key= NULL;
@@ -1116,7 +1116,7 @@ int Update_rows_log_event_old::do_after_row_operations(TABLE *table, int error)
{
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
table->file->ha_index_or_rnd_end();
- my_free(m_memory, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_memory);
m_memory= NULL;
m_after_image= NULL;
m_key= NULL;
@@ -1360,7 +1360,7 @@ Old_rows_log_event::~Old_rows_log_event()
if (m_cols.bitmap == m_bitbuf) // no my_malloc happened
m_cols.bitmap= 0; // so no my_free in bitmap_free
bitmap_free(&m_cols); // To pair with bitmap_init().
- my_free((uchar*)m_rows_buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_rows_buf);
}
@@ -2698,7 +2698,7 @@ Delete_rows_log_event_old::do_after_row_operations(const Slave_reporting_capabil
{
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
m_table->file->ha_index_or_rnd_end();
- my_free(m_key, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(m_key);
m_key= NULL;
return error;
@@ -2797,7 +2797,7 @@ Update_rows_log_event_old::do_after_row_operations(const Slave_reporting_capabil
{
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
m_table->file->ha_index_or_rnd_end();
- my_free(m_key, MYF(MY_ALLOW_ZERO_PTR)); // Free for multi_malloc
+ my_free(m_key); // Free for multi_malloc
m_key= NULL;
return error;
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 184b3c6051d..0426a410d98 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -1935,7 +1935,7 @@ bool MDL_context::acquire_locks(MDL_request_list *mdl_requests,
if (acquire_lock(*p_req, lock_wait_timeout))
goto err;
}
- my_free(sort_buf, MYF(0));
+ my_free(sort_buf);
return FALSE;
err:
@@ -1951,7 +1951,7 @@ err:
{
(*p_req)->ticket= NULL;
}
- my_free(sort_buf, MYF(0));
+ my_free(sort_buf);
return TRUE;
}
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 28cad51aa41..35d6137789d 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1523,7 +1523,7 @@ void clean_up(bool print_message)
if (defaults_argv)
free_defaults(defaults_argv);
free_tmpdir(&mysql_tmpdir_list);
- x_free(opt_bin_logname);
+ my_free(opt_bin_logname);
bitmap_free(&temp_pool);
free_max_user_conn();
#ifdef HAVE_REPLICATION
@@ -3135,7 +3135,7 @@ void *my_str_malloc_mysqld(size_t size)
void my_str_free_mysqld(void *ptr)
{
- my_free(ptr, MYF(MY_FAE));
+ my_free(ptr);
}
#endif /* EMBEDDED_LIBRARY */
@@ -3708,7 +3708,7 @@ static int init_common_variables()
#define FIX_LOG_VAR(VAR, ALT) \
if (!VAR || !*VAR) \
{ \
- x_free(VAR); /* it could be an allocated empty string "" */ \
+ my_free(VAR); /* it could be an allocated empty string "" */ \
VAR= my_strdup(ALT, MYF(0)); \
}
@@ -4144,7 +4144,7 @@ a file name for --log-bin-index option", opt_binlog_index_name);
}
if (ln == buf)
{
- my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(opt_bin_logname);
opt_bin_logname=my_strdup(buf, MYF(0));
}
if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln, TRUE))
@@ -5931,7 +5931,7 @@ errorconn:
/* End shared memory handling */
error:
if (tmp)
- my_free(tmp, MYF(0));
+ my_free(tmp);
if (errmsg)
{
@@ -6231,14 +6231,6 @@ struct my_option my_long_options[]=
"Don't allow new user creation by the user who has no write privileges to the mysql.user table.",
&opt_safe_user_create, &opt_safe_user_create, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
-#if !defined(DBUG_OFF) && defined(SAFEMALLOC)
- {"safemalloc", 0, "Enable the memory allocation checking.",
- &sf_malloc_quick, &sf_malloc_quick, 0,
- GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
- {"safemalloc-mem-limit", 0, "Simulate memory shortage.",
- &sf_malloc_mem_limit, &sf_malloc_mem_limit, 0, GET_UINT,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-#endif
{"show-slave-auth-info", 0,
"Show user and password in SHOW SLAVE HOSTS on this master.",
&opt_show_slave_auth_info, &opt_show_slave_auth_info, 0,
@@ -7867,7 +7859,7 @@ static int fix_paths(void)
}
char *secure_file_real_path= (char *)my_malloc(FN_REFLEN, MYF(MY_FAE));
convert_dirname(secure_file_real_path, buff, NullS);
- my_free(opt_secure_file_priv, MYF(0));
+ my_free(opt_secure_file_priv);
opt_secure_file_priv= secure_file_real_path;
}
}
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 918798529de..83435740ead 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -152,7 +152,7 @@ my_bool my_net_init(NET *net, Vio* vio)
void net_end(NET *net)
{
DBUG_ENTER("net_end");
- my_free(net->buff,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(net->buff);
net->buff=0;
DBUG_VOID_RETURN;
}
@@ -696,7 +696,7 @@ net_real_write(NET *net,const uchar *packet, size_t len)
#endif
#ifdef HAVE_COMPRESS
if (net->compress)
- my_free((char*) packet,MYF(0));
+ my_free((void*) packet);
#endif
if (thr_alarm_in_use(&alarmed))
{
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index f195da9ae02..48235ba588a 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1091,7 +1091,7 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
select->file= *head->sort.io_cache;
select->records=(ha_rows) (select->file.end_of_file/
head->file->ref_length);
- my_free(head->sort.io_cache, MYF(0));
+ my_free(head->sort.io_cache);
head->sort.io_cache=0;
}
DBUG_RETURN(select);
@@ -1216,11 +1216,11 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
}
delete_dynamic(&ranges); /* ranges are allocated in alloc */
free_root(&alloc,MYF(0));
- my_free((char*) column_bitmap.bitmap, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(column_bitmap.bitmap);
}
head->column_bitmaps_set(save_read_set, save_write_set);
- x_free(multi_range);
- x_free(multi_range_buff);
+ my_free(multi_range);
+ my_free(multi_range_buff);
DBUG_VOID_RETURN;
}
@@ -8589,7 +8589,7 @@ int QUICK_RANGE_SELECT::reset()
}
if (! multi_range_buff)
{
- my_free((char*) multi_range, MYF(0));
+ my_free(multi_range);
multi_range= NULL;
multi_range_length= 0;
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
diff --git a/sql/records.cc b/sql/records.cc
index 70b7cedb0a5..ccacdc33b36 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -293,7 +293,7 @@ void end_read_record(READ_RECORD *info)
{ /* free cache if used */
if (info->cache)
{
- my_free_lock((char*) info->cache,MYF(0));
+ my_free_lock(info->cache);
info->cache=0;
}
if (info->table)
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 81366d55fc6..9a1f7fb826b 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -205,7 +205,7 @@ int register_slave(THD* thd, uchar* packet, uint packet_length)
return res;
err:
- my_free(si, MYF(MY_WME));
+ my_free(si);
my_message(ER_UNKNOWN_ERROR, errmsg, MYF(0)); /* purecov: inspected */
err2:
return 1;
@@ -221,7 +221,7 @@ extern "C" uint32
extern "C" void slave_info_free(void *s)
{
- my_free(s, MYF(MY_WME));
+ my_free(s);
}
#ifdef HAVE_PSI_INTERFACE
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index 63521c0398f..42a9a034efd 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -383,7 +383,7 @@ void free_table_ent(void* a)
{
TABLE_RULE_ENT *e= (TABLE_RULE_ENT *) a;
- my_free((uchar*) e, MYF(0));
+ my_free(e);
}
@@ -434,7 +434,7 @@ Rpl_filter::free_string_array(DYNAMIC_ARRAY *a)
{
char* p;
get_dynamic(a, (uchar*) &p, i);
- my_free(p, MYF(MY_WME));
+ my_free(p);
}
delete_dynamic(a);
}
diff --git a/sql/rpl_handler.cc b/sql/rpl_handler.cc
index be0a61bcae2..55418cbec84 100644
--- a/sql/rpl_handler.cc
+++ b/sql/rpl_handler.cc
@@ -213,7 +213,7 @@ int Trans_delegate::after_commit(THD *thd, bool all)
if (is_real_trans && log_info)
{
my_pthread_setspecific_ptr(RPL_TRANS_BINLOG_INFO, NULL);
- my_free(log_info, MYF(0));
+ my_free(log_info);
}
return ret;
}
@@ -241,7 +241,7 @@ int Trans_delegate::after_rollback(THD *thd, bool all)
if (is_real_trans && log_info)
{
my_pthread_setspecific_ptr(RPL_TRANS_BINLOG_INFO, NULL);
- my_free(log_info, MYF(0));
+ my_free(log_info);
}
return ret;
}
diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc
index 0f636f5b2ab..75ccb617e9e 100644
--- a/sql/rpl_injector.cc
+++ b/sql/rpl_injector.cc
@@ -58,7 +58,7 @@ injector::transaction::~transaction()
*/
*the_memory= '\0';
- my_free(the_memory, MYF(0));
+ my_free(the_memory);
}
/**
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 443af94e0d0..308f6d7f06e 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -520,7 +520,7 @@ int flush_master_info(Master_info* mi,
(int)(mi->ssl), mi->ssl_ca, mi->ssl_capath, mi->ssl_cert,
mi->ssl_cipher, mi->ssl_key, mi->ssl_verify_server_cert,
heartbeat_buf, "", ignore_server_ids_buf);
- my_free(ignore_server_ids_buf, MYF(0));
+ my_free(ignore_server_ids_buf);
err= flush_io_cache(file);
if (sync_masterinfo_period && !err &&
++(mi->sync_counter) >= sync_masterinfo_period)
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 8f070c51410..08377fe887d 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -1251,7 +1251,7 @@ void Relay_log_info::clear_tables_to_lock()
tables_to_lock=
static_cast<RPL_TABLE_LIST*>(tables_to_lock->next_global);
tables_to_lock_count--;
- my_free(to_free, MYF(MY_WME));
+ my_free(to_free);
}
DBUG_ASSERT(tables_to_lock == NULL && tables_to_lock_count == 0);
}
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 0675e9b51ad..2c6a9e5d9b9 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -1047,7 +1047,7 @@ table_def::table_def(unsigned char *types, ulong size,
table_def::~table_def()
{
- my_free(m_memory, MYF(0));
+ my_free(m_memory);
#ifndef DBUG_OFF
m_type= 0;
m_size= 0;
diff --git a/sql/slave.cc b/sql/slave.cc
index bcb01d77e15..58b23c44bc7 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1154,7 +1154,7 @@ int init_dynarray_intvar_from_file(DYNAMIC_ARRAY* arr, IO_CACHE* f)
}
err:
if (buf_act != buf)
- my_free(buf_act, MYF(0));
+ my_free(buf_act);
DBUG_RETURN(ret);
}
@@ -3686,7 +3686,7 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
sql_print_error("Read invalid event from master: '%s',\
master could be corrupt but a more likely cause of this is a bug",
errmsg);
- my_free((char*) tmp_buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(tmp_buf);
DBUG_RETURN(1);
}
@@ -3723,7 +3723,7 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
mi->master_log_pos += inc_pos;
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
mysql_mutex_unlock(&mi->data_lock);
- my_free((char*)tmp_buf, MYF(0));
+ my_free(tmp_buf);
DBUG_RETURN(error);
}
default:
@@ -3774,7 +3774,7 @@ static int queue_binlog_ver_3_event(Master_info *mi, const char *buf,
sql_print_error("Read invalid event from master: '%s',\
master could be corrupt but a more likely cause of this is a bug",
errmsg);
- my_free((char*) tmp_buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(tmp_buf);
DBUG_RETURN(1);
}
mysql_mutex_lock(&mi->data_lock);
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index 74dda9f456b..bbf38f52efb 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -19,10 +19,6 @@
#pragma implementation
#endif
-#if defined(WIN32) || defined(__WIN__)
-#undef SAFEMALLOC /* Problems with threads */
-#endif
-
#include "sp_pcontext.h"
#include "sp_head.h"
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index e3cdf328659..047cec76486 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -19,10 +19,6 @@
#pragma implementation
#endif
-#if defined(WIN32) || defined(__WIN__)
-#undef SAFEMALLOC /* Problems with threads */
-#endif
-
#include "mysql.h"
#include "sp_head.h"
#include "sql_cursor.h"
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index a83c0b1c1fd..c3e26bb665d 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -885,7 +885,7 @@ static void free_cache_entry(TABLE *table)
intern_close_table(table);
- my_free((uchar*) table,MYF(0));
+ my_free(table);
DBUG_VOID_RETURN;
}
@@ -897,7 +897,7 @@ void free_io_cache(TABLE *table)
if (table->sort.io_cache)
{
close_cached_file(table->sort.io_cache);
- my_free((uchar*) table->sort.io_cache,MYF(0));
+ my_free(table->sort.io_cache);
table->sort.io_cache=0;
}
DBUG_VOID_RETURN;
@@ -2136,7 +2136,7 @@ void close_temporary(TABLE *table, bool free_share, bool delete_table)
if (free_share)
{
free_table_share(table->s);
- my_free((char*) table,MYF(0));
+ my_free(table);
}
DBUG_VOID_RETURN;
}
@@ -3018,7 +3018,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if (error)
{
- my_free(table, MYF(0));
+ my_free(table);
if (error == 7)
(void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER,
@@ -3033,7 +3033,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if (open_table_entry_fini(thd, share, table))
{
closefrm(table, 0);
- my_free((uchar*)table, MYF(0));
+ my_free(table);
goto err_lock;
}
@@ -3779,10 +3779,10 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
query, (ulong)(end-query),
FALSE, FALSE, FALSE, errcode))
{
- my_free(query, MYF(0));
+ my_free(query);
return TRUE;
}
- my_free(query, MYF(0));
+ my_free(query);
}
else
{
@@ -3867,7 +3867,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
closefrm(entry, 0);
result= FALSE;
}
- my_free(entry, MYF(0));
+ my_free(entry);
mysql_mutex_lock(&LOCK_open);
release_table_share(share);
@@ -5751,7 +5751,7 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
{
/* No need to lock share->mutex as this is not needed for tmp tables */
free_table_share(share);
- my_free((char*) tmp_table,MYF(0));
+ my_free(tmp_table);
DBUG_RETURN(0);
}
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index 0730f7df00c..52ac34b7b60 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -252,6 +252,6 @@ void mysql_client_binlog_statement(THD* thd)
end:
rli->slave_close_thread_tables(thd);
- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buf);
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 92d54c8e71b..b73de320ef5 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -2223,7 +2223,7 @@ void Query_cache::free_cache()
{
DBUG_ENTER("Query_cache::free_cache");
- my_free((uchar*) cache, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(cache);
make_disabled();
my_hash_free(&queries);
my_hash_free(&tables);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index e781f08b6d4..2fbdc2b58ac 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -100,8 +100,8 @@ extern "C" void free_user_var(user_var_entry *entry)
{
char *pos= (char*) entry+ALIGN_SIZE(sizeof(*entry));
if (entry->value && entry->value != pos)
- my_free(entry->value, MYF(0));
- my_free((char*) entry,MYF(0));
+ my_free(entry->value);
+ my_free(entry);
}
bool Key_part_spec::operator==(const Key_part_spec& other) const
@@ -1122,7 +1122,8 @@ THD::~THD()
DBUG_PRINT("info", ("freeing security context"));
main_security_ctx.destroy();
- safeFree(db);
+ my_free(db);
+ db= NULL;
free_root(&transaction.mem_root,MYF(0));
mysys_var=0; // Safety (shouldn't be needed)
mysql_mutex_destroy(&LOCK_thd_data);
@@ -2954,10 +2955,18 @@ void Security_context::destroy()
{
// If not pointer to constant
if (host != my_localhost)
- safeFree(host);
+ {
+ my_free(host);
+ host= NULL;
+ }
if (user != delayed_user)
- safeFree(user);
- safeFree(ip);
+ {
+ my_free(user);
+ user= NULL;
+ }
+
+ my_free(ip);
+ ip= NULL;
}
@@ -2973,7 +2982,7 @@ void Security_context::skip_grants()
bool Security_context::set_user(char *user_arg)
{
- safeFree(user);
+ my_free(user);
user= my_strdup(user_arg, MYF(0));
return user == 0;
}
@@ -3449,7 +3458,7 @@ uchar *xid_get_hash_key(const uchar *ptr, size_t *length,
void xid_free_hash(void *ptr)
{
if (!((XID_STATE*)ptr)->in_thd)
- my_free((uchar*)ptr, MYF(0));
+ my_free(ptr);
}
#ifdef HAVE_PSI_INTERFACE
@@ -4256,7 +4265,7 @@ CPP_UNNAMED_NS_START
~Row_data_memory()
{
if (m_memory != 0 && m_release_memory_on_destruction)
- my_free((uchar*) m_memory, MYF(MY_WME));
+ my_free(m_memory);
}
/**
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 7808cbe4d41..db22fc5d67b 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -2657,7 +2657,7 @@ public:
memcpy(db, new_db, new_db_len+1);
else
{
- x_free(db);
+ my_free(db);
if (new_db)
db= my_strndup(new_db, new_db_len, MYF(MY_WME | ME_FATALERROR));
else
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 35ba39afd81..05d20b386dd 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -98,7 +98,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
if (my_hash_insert(&hash_user_connections, (uchar*) uc))
{
/* The only possible error is out of memory, MY_WME sets an error. */
- my_free((char*) uc,0);
+ my_free(uc);
return_val= 1;
goto end;
}
@@ -555,7 +555,7 @@ extern "C" uchar *get_key_conn(user_conn *buff, size_t *length,
extern "C" void free_user(struct user_conn *uc)
{
- my_free((char*) uc,MYF(0));
+ my_free(uc);
}
@@ -940,8 +940,7 @@ static int check_connection(THD *thd)
user_len-= 2;
}
- if (thd->main_security_ctx.user)
- x_free(thd->main_security_ctx.user);
+ my_free(thd->main_security_ctx.user);
if (!(thd->main_security_ctx.user= my_strdup(user, MYF(MY_WME))))
return 1; /* The error is set by my_strdup(). */
return check_user(thd, COM_CONNECT, passwd, passwd_len, db, TRUE);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 2e48475f298..1040fc92851 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -94,7 +94,7 @@ extern "C" void lock_db_free_element(void *ptr);
void lock_db_free_element(void *ptr)
{
- my_free(ptr, MYF(0));
+ my_free(ptr);
}
@@ -136,7 +136,7 @@ static my_bool lock_db_insert(const char *dbname, uint length)
opt->name_length= length;
if ((error= my_hash_insert(&lock_db_cache, (uchar*) opt)))
- my_free(opt, MYF(0));
+ my_free(opt);
}
end:
@@ -209,7 +209,7 @@ extern "C" void free_dbopt(void *dbopt);
void free_dbopt(void *dbopt)
{
- my_free((uchar*) dbopt, MYF(0));
+ my_free(dbopt);
}
#ifdef HAVE_PSI_INTERFACE
@@ -377,7 +377,7 @@ static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create)
if ((error= my_hash_insert(&dboptions, (uchar*) opt)))
{
- my_free(opt, MYF(0));
+ my_free(opt);
goto end;
}
}
@@ -1438,8 +1438,7 @@ static void mysql_change_db_impl(THD *thd,
we just call THD::reset_db(). Since THD::reset_db() does not releases
the previous database name, we should do it explicitly.
*/
-
- x_free(thd->db);
+ my_free(thd->db);
thd->reset_db(new_db_name->str, new_db_name->length);
}
@@ -1652,7 +1651,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
if (check_db_name(&new_db_file_name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), new_db_file_name.str);
- my_free(new_db_file_name.str, MYF(0));
+ my_free(new_db_file_name.str);
if (force_switch)
mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
@@ -1682,7 +1681,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
new_db_file_name.str);
general_log_print(thd, COM_INIT_DB, ER(ER_DBACCESS_DENIED_ERROR),
sctx->priv_user, sctx->priv_host, new_db_file_name.str);
- my_free(new_db_file_name.str, MYF(0));
+ my_free(new_db_file_name.str);
DBUG_RETURN(TRUE);
}
#endif
@@ -1697,7 +1696,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
ER_BAD_DB_ERROR, ER(ER_BAD_DB_ERROR),
new_db_file_name.str);
- my_free(new_db_file_name.str, MYF(0));
+ my_free(new_db_file_name.str);
/* Change db to NULL. */
@@ -1712,7 +1711,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
/* Report an error and free new_db_file_name. */
my_error(ER_BAD_DB_ERROR, MYF(0), new_db_file_name.str);
- my_free(new_db_file_name.str, MYF(0));
+ my_free(new_db_file_name.str);
/* The operation failed. */
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index d6f2a472e05..06a453f7b12 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -109,7 +109,7 @@ static char *mysql_ha_hash_get_key(TABLE_LIST *tables, size_t *key_len_p,
static void mysql_ha_hash_free(TABLE_LIST *tables)
{
- my_free((char*) tables, MYF(0));
+ my_free(tables);
}
/**
@@ -259,7 +259,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
/* add to hash */
if (my_hash_insert(&thd->handler_tables_hash, (uchar*) hash_tables))
{
- my_free((char*) hash_tables, MYF(0));
+ my_free(hash_tables);
DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(TRUE);
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 24a418f8f25..c783d74b363 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -93,7 +93,7 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view);
#define my_safe_afree(ptr, size, min_length) my_afree(ptr)
#else
#define my_safe_alloca(size, min_length) ((size <= min_length) ? my_alloca(size) : my_malloc(size,MYF(0)))
-#define my_safe_afree(ptr, size, min_length) if (size > min_length) my_free(ptr,MYF(0))
+#define my_safe_afree(ptr, size, min_length) if (size > min_length) my_free(ptr)
#endif
/*
@@ -1779,8 +1779,8 @@ public:
{}
~delayed_row()
{
- x_free(query.str);
- x_free(record);
+ my_free(query.str);
+ my_free(record);
}
};
@@ -1868,7 +1868,7 @@ public:
mysql_cond_destroy(&cond);
mysql_cond_destroy(&cond_client);
thd.unlink(); // Must be unlinked under lock
- x_free(thd.query());
+ my_free(thd.query());
thd.security_ctx->user= thd.security_ctx->host=0;
thread_count--;
delayed_insert_threads--;
@@ -2276,7 +2276,7 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
row= new delayed_row(query, duplic, ignore, log_on);
if (row == NULL)
{
- my_free(query.str, MYF(MY_WME));
+ my_free(query.str);
goto err;
}
@@ -2680,7 +2680,7 @@ static void free_delayed_insert_blobs(register TABLE *table)
{
uchar *str;
((Field_blob *) (*ptr))->get_ptr(&str);
- my_free(str,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(str);
((Field_blob *) (*ptr))->reset();
}
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 5f8b1148dcb..aefddc0b6a5 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -457,8 +457,8 @@ Yacc_state::~Yacc_state()
{
if (yacc_yyss)
{
- my_free(yacc_yyss, MYF(0));
- my_free(yacc_yyvs, MYF(0));
+ my_free(yacc_yyss);
+ my_free(yacc_yyvs);
}
}
diff --git a/sql/sql_list.h b/sql/sql_list.h
index d57534b0999..cc42fcae91b 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -534,7 +534,7 @@ struct ilink
}
static void operator delete(void* ptr_arg, size_t size)
{
- my_free((uchar*)ptr_arg, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
+ my_free(ptr_arg);
}
inline ilink()
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 7e540ffbe4b..9a5792407b1 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -1337,7 +1337,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs,
(is_fifo ? READ_FIFO : READ_CACHE),0L,1,
MYF(MY_WME)))
{
- my_free((uchar*) buffer,MYF(0)); /* purecov: inspected */
+ my_free(buffer); /* purecov: inspected */
error=1;
}
else
@@ -1368,7 +1368,7 @@ READ_INFO::~READ_INFO()
{
if (need_end_io_cache)
::end_io_cache(&cache);
- my_free((uchar*) buffer,MYF(0));
+ my_free(buffer);
error=1;
}
List_iterator<XML_TAG> xmlit(taglist);
diff --git a/sql/sql_locale.cc b/sql/sql_locale.cc
index abd9c395083..c8aee307362 100644
--- a/sql/sql_locale.cc
+++ b/sql/sql_locale.cc
@@ -3442,6 +3442,6 @@ void cleanup_errmsgs()
{
for (MY_LOCALE_ERRMSGS *msgs= global_errmsgs; msgs->language; msgs++)
{
- my_free(msgs->errmsgs, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
+ my_free(msgs->errmsgs);
}
}
diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc
index 2189b1e124f..e3929066361 100644
--- a/sql/sql_manager.cc
+++ b/sql/sql_manager.cc
@@ -117,7 +117,7 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused)))
{
struct handler_cb *next= cb->next;
cb->action();
- my_free((uchar*)cb, MYF(0));
+ my_free(cb);
cb= next;
}
}
diff --git a/sql/sql_map.cc b/sql/sql_map.cc
index 35a248e5465..ca8a88bcbf8 100644
--- a/sql/sql_map.cc
+++ b/sql/sql_map.cc
@@ -74,7 +74,7 @@ mapped_files::~mapped_files()
(void) mysql_file_close(file, MYF(0));
file= -1; map=0;
}
- my_free(name,MYF(0));
+ my_free(name);
#endif
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index b48491577d1..a7d538dd3e8 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1058,7 +1058,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (res)
{
- x_free(thd->security_ctx->user);
+ my_free(thd->security_ctx->user);
*thd->security_ctx= save_security_ctx;
thd->user_connect= save_user_connect;
thd->db= save_db;
@@ -1071,8 +1071,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (save_user_connect)
decrease_user_connections(save_user_connect);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
- x_free(save_db);
- x_free(save_security_ctx.user);
+ my_free(save_db);
+ my_free(save_security_ctx.user);
if (cs_number)
{
@@ -1415,18 +1415,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#ifdef EMBEDDED_LIBRARY
/* Store the buffer in permanent memory */
my_ok(thd, 0, 0, buff);
-#endif
-#ifdef SAFEMALLOC
- if (sf_malloc_cur_memory) // Using SAFEMALLOC
- {
- char *end= buff + length;
- length+= my_snprintf(end, buff_len - length - 1,
- end," Memory in use: %ldK Max memory used: %ldK",
- (sf_malloc_cur_memory+1023L)/1024L,
- (sf_malloc_max_memory+1023L)/1024L);
- }
-#endif
-#ifndef EMBEDDED_LIBRARY
+#else
(void) my_net_write(net, (uchar*) buff, length);
(void) net_flush(net);
thd->stmt_da->disable_status();
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index bc9a7d8ee65..d7ff753dfd0 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -2624,7 +2624,7 @@ char *generate_partition_syntax(partition_info *part_info,
if (unlikely(mysql_file_read(fptr, (uchar*)buf, *buf_length, MYF(MY_FNABP))))
{
if (!use_sql_alloc)
- my_free(buf, MYF(0));
+ my_free(buf);
else
buf= NULL;
}
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 97c480ea0bd..2b6be403fc6 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -254,10 +254,9 @@ static void plugin_vars_free_values(sys_var *vars);
static void restore_pluginvar_names(sys_var *first);
static void plugin_opt_set_limits(struct my_option *,
const struct st_mysql_sys_var *);
-#define my_intern_plugin_lock(A,B) intern_plugin_lock(A,B CALLER_INFO)
-#define my_intern_plugin_lock_ci(A,B) intern_plugin_lock(A,B ORIG_CALLER_INFO)
-static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref plugin
- CALLER_INFO_PROTO);
+#define my_intern_plugin_lock(A,B) intern_plugin_lock(A,B)
+#define my_intern_plugin_lock_ci(A,B) intern_plugin_lock(A,B)
+static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref plugin);
static void intern_plugin_unlock(LEX *lex, plugin_ref plugin);
static void reap_plugins(void);
@@ -392,9 +391,9 @@ static inline void free_plugin_mem(struct st_plugin_dl *p)
if (p->handle)
dlclose(p->handle);
#endif
- my_free(p->dl.str, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(p->dl.str);
if (p->version != MYSQL_PLUGIN_INTERFACE_VERSION)
- my_free((uchar*)p->plugins, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(p->plugins);
}
@@ -660,7 +659,7 @@ SHOW_COMP_OPTION plugin_status(const char *name, int len, size_t type)
}
-static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc CALLER_INFO_PROTO)
+static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc)
{
st_plugin_int *pi= plugin_ref_to_int(rc);
DBUG_ENTER("intern_plugin_lock");
@@ -682,7 +681,7 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc CALLER_INFO_PROTO)
memory manager and/or valgrind to track locked references and
double unlocks to aid resolving reference counting problems.
*/
- if (!(plugin= (plugin_ref) my_malloc_ci(sizeof(pi), MYF(MY_WME))))
+ if (!(plugin= (plugin_ref) my_malloc(sizeof(pi), MYF(MY_WME))))
DBUG_RETURN(NULL);
*plugin= pi;
@@ -699,7 +698,7 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc CALLER_INFO_PROTO)
}
-plugin_ref plugin_lock(THD *thd, plugin_ref *ptr CALLER_INFO_PROTO)
+plugin_ref plugin_lock(THD *thd, plugin_ref *ptr)
{
LEX *lex= thd ? thd->lex : 0;
plugin_ref rc;
@@ -711,8 +710,7 @@ plugin_ref plugin_lock(THD *thd, plugin_ref *ptr CALLER_INFO_PROTO)
}
-plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name, int type
- CALLER_INFO_PROTO)
+plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name, int type)
{
LEX *lex= thd ? thd->lex : 0;
plugin_ref rc= NULL;
@@ -973,7 +971,7 @@ static void intern_plugin_unlock(LEX *lex, plugin_ref plugin)
if (!pi->plugin_dl)
DBUG_VOID_RETURN;
#else
- my_free((uchar*) plugin, MYF(MY_WME));
+ my_free(plugin);
#endif
DBUG_PRINT("info",("unlocking plugin, name= %s, ref_count= %d",
@@ -2245,7 +2243,7 @@ static void update_func_str(THD *thd, struct st_mysql_sys_var *var,
if (var->flags & PLUGIN_VAR_MEMALLOC)
{
*(char **)tgt= my_strdup(*(char **) save, MYF(0));
- my_free(old, MYF(0));
+ my_free(old);
}
}
@@ -2637,7 +2635,7 @@ static void cleanup_variables(THD *thd, struct system_variables *vars)
flags & PLUGIN_VAR_THDLOCAL && flags & PLUGIN_VAR_MEMALLOC)
{
char **ptr= (char**) pivar->real_value_ptr(thd, OPT_SESSION);
- my_free(*ptr, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
+ my_free(*ptr);
*ptr= NULL;
}
}
@@ -2645,7 +2643,7 @@ static void cleanup_variables(THD *thd, struct system_variables *vars)
DBUG_ASSERT(vars->table_plugin == NULL);
- my_free(vars->dynamic_variables_ptr, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(vars->dynamic_variables_ptr);
vars->dynamic_variables_ptr= NULL;
vars->dynamic_variables_size= 0;
vars->dynamic_variables_version= 0;
@@ -2706,7 +2704,7 @@ static void plugin_vars_free_values(sys_var *vars)
char **valptr= (char**) piv->real_value_ptr(NULL, OPT_GLOBAL);
DBUG_PRINT("plugin", ("freeing value for: '%s' addr: 0x%lx",
var->name.str, (long) valptr));
- my_free(*valptr, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
+ my_free(*valptr);
*valptr= NULL;
}
}
diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h
index e7ecca029b9..079dc4e6dca 100644
--- a/sql/sql_plugin.h
+++ b/sql/sql_plugin.h
@@ -30,8 +30,6 @@
#include "m_string.h" /* LEX_STRING */
#include "my_alloc.h" /* MEM_ROOT */
-#include "my_sys.h" /* CALLER_INFO_PROTO */
-
class sys_var;
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
@@ -134,13 +132,13 @@ extern int plugin_init(int *argc, char **argv, int init_flags);
extern void plugin_shutdown(void);
void add_plugin_options(DYNAMIC_ARRAY *options, MEM_ROOT *mem_root);
extern bool plugin_is_ready(const LEX_STRING *name, int type);
-#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C CALLER_INFO)
-#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C ORIG_CALLER_INFO)
-#define my_plugin_lock(A,B) plugin_lock(A,B CALLER_INFO)
-#define my_plugin_lock_ci(A,B) plugin_lock(A,B ORIG_CALLER_INFO)
-extern plugin_ref plugin_lock(THD *thd, plugin_ref *ptr CALLER_INFO_PROTO);
+#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C)
+#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C)
+#define my_plugin_lock(A,B) plugin_lock(A,B)
+#define my_plugin_lock_ci(A,B) plugin_lock(A,B)
+extern plugin_ref plugin_lock(THD *thd, plugin_ref *ptr);
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
- int type CALLER_INFO_PROTO);
+ int type);
extern void plugin_unlock(THD *thd, plugin_ref plugin);
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint count);
extern bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index 4a0d3d944ad..ce3d786cf92 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -177,8 +177,7 @@ PROF_MEASUREMENT::PROF_MEASUREMENT(QUERY_PROFILE *profile_arg,
PROF_MEASUREMENT::~PROF_MEASUREMENT()
{
- if (allocated_status_memory != NULL)
- my_free(allocated_status_memory, MYF(0));
+ my_free(allocated_status_memory);
status= function= file= NULL;
}
@@ -268,8 +267,7 @@ QUERY_PROFILE::~QUERY_PROFILE()
while (! entries.is_empty())
delete entries.pop();
- if (query_source != NULL)
- my_free(query_source, MYF(0));
+ my_free(query_source);
}
/**
diff --git a/sql/sql_profile.h b/sql/sql_profile.h
index ff16a2da19b..7d17dc69b88 100644
--- a/sql/sql_profile.h
+++ b/sql/sql_profile.h
@@ -82,7 +82,7 @@ public:
for (i= first; i != NULL; i= after_i)
{
after_i= i->next;
- my_free((char *) i, MYF(0));
+ my_free(i);
}
elements= 0;
}
@@ -129,7 +129,7 @@ public:
last= NULL;
first= first->next;
- my_free((char *)old_item, MYF(0));
+ my_free(old_item);
elements--;
return ret;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 22190eeefed..24d2a21147c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6957,7 +6957,7 @@ void JOIN_TAB::cleanup()
select= 0;
delete quick;
quick= 0;
- x_free(cache.buff);
+ my_free(cache.buff);
cache.buff= 0;
limit= 0;
if (table)
@@ -14251,7 +14251,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
if (my_hash_init(&hash, &my_charset_bin, (uint) file->stats.records, 0,
key_length, (my_hash_get_key) 0, 0, 0))
{
- my_free((char*) key_buffer,MYF(0));
+ my_free(key_buffer);
DBUG_RETURN(1);
}
@@ -14303,14 +14303,14 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
}
key_pos+=extra_length;
}
- my_free((char*) key_buffer,MYF(0));
+ my_free(key_buffer);
my_hash_free(&hash);
file->extra(HA_EXTRA_NO_CACHE);
(void) file->ha_rnd_end();
DBUG_RETURN(0);
err:
- my_free((char*) key_buffer,MYF(0));
+ my_free(key_buffer);
my_hash_free(&hash);
file->extra(HA_EXTRA_NO_CACHE);
(void) file->ha_rnd_end();
@@ -14393,7 +14393,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count)
sizeof(CACHE_FIELD*))))
{
- my_free((uchar*) cache->buff,MYF(0)); /* purecov: inspected */
+ my_free(cache->buff); /* purecov: inspected */
cache->buff=0; /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index f1d7e48ffcc..fc2f22f6f48 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1353,7 +1353,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN(" /*!50100 TABLESPACE "));
packet->append(for_str, strlen(for_str));
packet->append(STRING_WITH_LEN(" STORAGE DISK */"));
- my_free(for_str, MYF(0));
+ my_free(for_str);
}
/*
@@ -1495,7 +1495,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
table->part_info->set_show_version_string(packet);
packet->append(part_syntax, part_syntax_len);
packet->append(STRING_WITH_LEN(" */"));
- my_free(part_syntax, MYF(0));
+ my_free(part_syntax);
}
}
#endif
@@ -3323,7 +3323,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables,
res= schema_table->process_table(thd, &table_list, table,
res, db_name, table_name);
free_root(&tbl.mem_root, MYF(0));
- my_free((char*) tbl.alias, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((void *) tbl.alias);
}
end_share:
@@ -5375,7 +5375,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table,
if(ts)
{
table->field[24]->store(ts, strlen(ts), cs);
- my_free(ts, MYF(0));
+ my_free(ts);
}
else
table->field[24]->set_null();
@@ -7470,7 +7470,7 @@ int initialize_schema_table(st_plugin_int *plugin)
sql_print_error("Plugin '%s' init function returned error.",
plugin->name.str);
plugin->data= NULL;
- my_free(schema_table, MYF(0));
+ my_free(schema_table);
DBUG_RETURN(1);
}
@@ -7493,7 +7493,7 @@ int finalize_schema_table(st_plugin_int *plugin)
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
plugin->name.str));
}
- my_free(schema_table, MYF(0));
+ my_free(schema_table);
}
DBUG_RETURN(0);
}
diff --git a/sql/sql_string.h b/sql/sql_string.h
index debfb7aa9c6..0ce67108423 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -205,7 +205,7 @@ public:
{
alloced=0;
Alloced_length=0;
- my_free(Ptr,MYF(0));
+ my_free(Ptr);
Ptr=0;
str_length=0; /* Safety */
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f300ecec2c6..fa9f9b7f633 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1534,13 +1534,13 @@ void release_ddl_log()
while (used_list)
{
DDL_LOG_MEMORY_ENTRY *tmp= used_list->next_log_entry;
- my_free(used_list, MYF(0));
+ my_free(used_list);
used_list= tmp;
}
while (free_list)
{
DDL_LOG_MEMORY_ENTRY *tmp= free_list->next_log_entry;
- my_free(free_list, MYF(0));
+ my_free(free_list);
free_list= tmp;
}
close_ddl_log();
@@ -1696,8 +1696,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
if (readfrm(shadow_path, &data, &length) ||
packfrm(data, length, &lpt->pack_frm_data, &lpt->pack_frm_len))
{
- my_free(data, MYF(MY_ALLOW_ZERO_PTR));
- my_free(lpt->pack_frm_data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(data);
+ my_free(lpt->pack_frm_data);
mem_alloc_error(length);
error= 1;
goto end;
@@ -7534,7 +7534,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (t_table)
{
intern_close_table(t_table);
- my_free(t_table, MYF(0));
+ my_free(t_table);
}
else
sql_print_warning("Could not open table %s.%s after rename\n",
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 48fd5f9dff8..501c4cf6a94 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -555,11 +555,6 @@ Next alarm time: %lu\n",
#endif
display_table_locks();
fflush(stdout);
- my_checkmalloc();
- fprintf(stdout,"\nBegin safemalloc memory dump:\n"); // tag needed for test suite
- TERMINATE(stdout, 1); // Write malloc information
- fprintf(stdout,"\nEnd safemalloc memory dump.\n");
- fflush(stdout);
#ifdef HAVE_MALLINFO
struct mallinfo info= mallinfo();
printf("\nMemory status:\n\
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc
index 901ab8e987d..c2482ef1ce0 100644
--- a/sql/sql_truncate.cc
+++ b/sql/sql_truncate.cc
@@ -216,7 +216,7 @@ static bool recreate_temporary_table(THD *thd, TABLE *table)
rm_temporary_table(table_type, share->path.str);
free_table_share(share);
- my_free(table, MYF(0));
+ my_free(table);
DBUG_RETURN(error);
}
diff --git a/sql/sys_vars.h b/sql/sys_vars.h
index fbc48573487..18c073b1e90 100644
--- a/sql/sys_vars.h
+++ b/sql/sys_vars.h
@@ -388,7 +388,7 @@ public:
~Sys_var_charptr()
{
if (flags & ALLOCATED)
- my_free(global_var(char*), MYF(MY_ALLOW_ZERO_PTR));
+ my_free(global_var(char*));
flags&= ~ALLOCATED;
}
bool do_check(THD *thd, set_var *var)
@@ -435,7 +435,7 @@ public:
else
new_val= 0;
if (flags & ALLOCATED)
- my_free(global_var(char*), MYF(MY_ALLOW_ZERO_PTR));
+ my_free(global_var(char*));
flags|= ALLOCATED;
global_var(char*)= new_val;
return false;
diff --git a/sql/table.cc b/sql/table.cc
index 4e6f2ae2860..a58623f0036 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -896,7 +896,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (mysql_file_pread(file, buff, n_length, record_offset + share->reclength,
MYF(MY_NABP)))
{
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
share->connect_string.length= uint2korr(buff);
@@ -905,7 +905,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
share->connect_string.
length)))
{
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
next_chunk+= share->connect_string.length + 2;
@@ -926,7 +926,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
plugin_data(tmp_plugin, handlerton *)))
{
/* bad file, legacy_db_type did not match the name */
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
/*
@@ -956,7 +956,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
error= 8;
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0),
"--skip-partition");
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
plugin_unlock(NULL, share->db_plugin);
@@ -972,7 +972,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
error= 8;
name.str[name.length]=0;
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), name.str);
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
/* purecov: end */
}
@@ -989,7 +989,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
memdup_root(&share->mem_root, next_chunk + 4,
partition_info_str_len + 1)))
{
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
}
@@ -997,7 +997,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (partition_info_str_len)
{
DBUG_PRINT("info", ("WITH_PARTITION_STORAGE_ENGINE is not defined"));
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
#endif
@@ -1035,7 +1035,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
{
DBUG_PRINT("error",
("fulltext key uses parser that is not defined in .frm"));
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
parser_name.str= (char*) next_chunk;
@@ -1046,7 +1046,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (! keyinfo->parser)
{
my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), parser_name.str);
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
}
@@ -1058,19 +1058,19 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
{
DBUG_PRINT("error",
("long table comment is not defined in .frm"));
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
share->comment.length = uint2korr(next_chunk);
if (! (share->comment.str= strmake_root(&share->mem_root,
(char*)next_chunk + 2, share->comment.length)))
{
- my_free(buff, MYF(0));
+ my_free(buff);
goto err;
}
next_chunk+= 2 + share->comment.length;
}
- my_free(buff, MYF(0));
+ my_free(buff);
}
share->key_block_size= uint2korr(head+62);
@@ -1586,7 +1586,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
}
else
share->primary_key= MAX_KEY;
- x_free((uchar*) disk_buff);
+ my_free(disk_buff);
disk_buff=0;
if (new_field_pack_flag <= 1)
{
@@ -1658,7 +1658,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
share->error= error;
share->open_errno= my_errno;
share->errarg= errarg;
- x_free((uchar*) disk_buff);
+ my_free(disk_buff);
delete crypted;
delete handler_file;
my_hash_free(&share->name_hash);
@@ -2010,7 +2010,7 @@ partititon_err:
outparam->file= 0; // For easier error checking
outparam->db_stat=0;
free_root(&outparam->mem_root, MYF(0)); // Safe to call on bzero'd root
- my_free((char*) outparam->alias, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((void *) outparam->alias);
DBUG_RETURN (error);
}
@@ -2032,7 +2032,7 @@ int closefrm(register TABLE *table, bool free_share)
if (table->db_stat)
error=table->file->close();
- my_free((char*) table->alias, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((void *) table->alias);
table->alias= 0;
if (table->field)
{
@@ -2127,14 +2127,14 @@ static ulong get_form_pos(File file, uchar *head)
if (mysql_file_read(file, buf, length+names*4, MYF(MY_NABP)))
{
- x_free(buf);
+ my_free(buf);
DBUG_RETURN(0);
}
pos= buf+length;
ret_value= uint4korr(pos);
- my_free(buf, MYF(0));
+ my_free(buf);
DBUG_RETURN(ret_value);
}
@@ -2151,11 +2151,11 @@ int read_string(File file, uchar**to, size_t length)
{
DBUG_ENTER("read_string");
- x_free(*to);
+ my_free(*to);
if (!(*to= (uchar*) my_malloc(length+1,MYF(MY_WME))) ||
mysql_file_read(file, *to, length, MYF(MY_NABP)))
{
- x_free(*to); /* purecov: inspected */
+ my_free(*to); /* purecov: inspected */
*to= 0; /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
}
diff --git a/sql/uniques.cc b/sql/uniques.cc
index 7b5a6d1ce4f..690b310bde5 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -566,7 +566,7 @@ bool Unique::walk(tree_walk_action action, void *walk_action_arg)
(BUFFPEK *) file_ptrs.buffer + file_ptrs.elements,
action, walk_action_arg,
tree.compare, tree.custom_arg, &file);
- my_free((char*) merge_buffer, MYF(0));
+ my_free(merge_buffer);
return res;
}
@@ -642,7 +642,7 @@ bool Unique::get(TABLE *table)
goto err;
error=0;
err:
- x_free(sort_buffer);
+ my_free(sort_buffer);
if (flush_io_cache(outfile))
error=1;
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 802e5b7429c..6433b8bc7c2 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -148,7 +148,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
if (error)
{
- my_free(screen_buff, MYF(0));
+ my_free(screen_buff);
if (! pack_header_error_handler.is_handled)
DBUG_RETURN(1);
@@ -159,7 +159,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
create_fields,info_length,
screens, create_info->table_options, data_offset, db_file))
{
- my_free(screen_buff, MYF(0));
+ my_free(screen_buff);
DBUG_RETURN(1);
}
}
@@ -228,7 +228,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
{
my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0),
real_table_name, (uint) TABLE_COMMENT_MAXLEN);
- my_free(screen_buff,MYF(0));
+ my_free(screen_buff);
DBUG_RETURN(1);
}
char warn_buff[MYSQL_ERRMSG_SIZE];
@@ -259,7 +259,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo,
create_info, keys, key_info)) < 0)
{
- my_free(screen_buff, MYF(0));
+ my_free(screen_buff);
DBUG_RETURN(1);
}
@@ -374,15 +374,15 @@ bool mysql_create_frm(THD *thd, const char *file_name,
delete crypted;
if (mysql_file_pwrite(file, disk_buff, read_length, filepos+256, MYF_RW))
{
- my_free(disk_buff,MYF(0));
+ my_free(disk_buff);
goto err;
}
- my_free(disk_buff,MYF(0));
+ my_free(disk_buff);
}
#endif
- my_free(screen_buff,MYF(0));
- my_free(keybuff, MYF(0));
+ my_free(screen_buff);
+ my_free(keybuff);
if (opt_sync_frm && !(create_info->options & HA_LEX_CREATE_TMP_TABLE) &&
(mysql_file_sync(file, MYF(MY_WME)) ||
@@ -411,8 +411,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
DBUG_RETURN(0);
err:
- my_free(screen_buff, MYF(0));
- my_free(keybuff, MYF(0));
+ my_free(screen_buff);
+ my_free(keybuff);
err2:
(void) mysql_file_close(file, MYF(MY_WME));
err3:
@@ -1095,7 +1095,7 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
error= mysql_file_write(file, buff, (size_t) reclength, MYF_RW) != 0;
err:
- my_free(buff, MYF(MY_FAE));
+ my_free(buff);
thd->count_cuted_fields= old_count_cuted_fields;
DBUG_RETURN(error);
} /* make_empty_rec */
diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c
index bad02835d86..ce4be92a521 100644
--- a/storage/archive/archive_reader.c
+++ b/storage/archive/archive_reader.c
@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
ptr= (char *)my_malloc(sizeof(char) * reader_handle.frm_length, MYF(0));
azread_frm(&reader_handle, ptr);
azwrite_frm(&writer_handle, ptr, reader_handle.frm_length);
- my_free(ptr, MYF(0));
+ my_free(ptr);
}
if (reader_handle.comment_length)
@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
ptr= (char *)my_malloc(sizeof(char) * reader_handle.comment_length, MYF(0));
azread_comment(&reader_handle, ptr);
azwrite_comment(&writer_handle, ptr, reader_handle.comment_length);
- my_free(ptr, MYF(0));
+ my_free(ptr);
}
while ((read= azread(&reader_handle, (uchar *)size_buffer,
@@ -265,7 +265,7 @@ int main(int argc, char *argv[])
azread_frm(&reader_handle, ptr);
my_write(frm_file, (uchar*) ptr, reader_handle.frm_length, MYF(0));
my_close(frm_file, MYF(0));
- my_free(ptr, MYF(0));
+ my_free(ptr);
}
end:
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index 2bcfc3ff672..63848370ff1 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -387,7 +387,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
{
*rc= my_errno ? my_errno : -1;
mysql_mutex_unlock(&archive_mutex);
- my_free(share, MYF(0));
+ my_free(share);
DBUG_RETURN(NULL);
}
stats.auto_increment_value= archive_tmp.auto_increment + 1;
@@ -447,7 +447,7 @@ int ha_archive::free_share()
if (azclose(&(share->archive_write)))
rc= 1;
}
- my_free((uchar*) share, MYF(0));
+ my_free(share);
}
mysql_mutex_unlock(&archive_mutex);
@@ -706,7 +706,7 @@ int ha_archive::create(const char *name, TABLE *table_arg,
{
my_read(frm_file, frm_ptr, file_stat.st_size, MYF(0));
azwrite_frm(&create_stream, (char *)frm_ptr, file_stat.st_size);
- my_free((uchar*)frm_ptr, MYF(0));
+ my_free(frm_ptr);
}
}
my_close(frm_file, MYF(0));
@@ -932,8 +932,7 @@ int ha_archive::write_row(uchar *buf)
rc= real_write_row(buf, &(share->archive_write));
error:
mysql_mutex_unlock(&share->mutex);
- if (read_buf)
- my_free((uchar*) read_buf, MYF(0));
+ my_free(read_buf);
DBUG_RETURN(rc);
}
@@ -1696,7 +1695,7 @@ archive_record_buffer *ha_archive::create_record_buffer(unsigned int length)
if (!(r->buffer= (uchar*) my_malloc(r->length,
MYF(MY_WME))))
{
- my_free((char*) r, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(r);
DBUG_RETURN(NULL); /* purecov: inspected */
}
@@ -1706,8 +1705,8 @@ archive_record_buffer *ha_archive::create_record_buffer(unsigned int length)
void ha_archive::destroy_record_buffer(archive_record_buffer *r)
{
DBUG_ENTER("ha_archive::destroy_record_buffer");
- my_free((char*) r->buffer, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*) r, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(r->buffer);
+ my_free(r);
DBUG_VOID_RETURN;
}
diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc
index 7ec60aad88a..6591c3a2c78 100644
--- a/storage/blackhole/ha_blackhole.cc
+++ b/storage/blackhole/ha_blackhole.cc
@@ -335,7 +335,7 @@ static st_blackhole_share *get_share(const char *table_name)
if (my_hash_insert(&blackhole_open_tables, (uchar*) share))
{
- my_free((uchar*) share, MYF(0));
+ my_free(share);
share= NULL;
goto error;
}
@@ -360,7 +360,7 @@ static void free_share(st_blackhole_share *share)
static void blackhole_free_key(st_blackhole_share *share)
{
thr_lock_delete(&share->lock);
- my_free((uchar*) share, MYF(0));
+ my_free(share);
}
static uchar* blackhole_get_key(st_blackhole_share *share, size_t *length,
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index 11edf690f2a..30c4c4d58ca 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -251,7 +251,7 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
error:
mysql_mutex_unlock(&tina_mutex);
- my_free((uchar*) share, MYF(0));
+ my_free(share);
return NULL;
}
@@ -429,7 +429,7 @@ static int free_share(TINA_SHARE *share)
my_hash_delete(&tina_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
mysql_mutex_destroy(&share->mutex);
- my_free((uchar*) share, MYF(0));
+ my_free(share);
}
mysql_mutex_unlock(&tina_mutex);
@@ -1529,7 +1529,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
free_root(&blobroot, MYF(0));
- my_free((char*)buf, MYF(0));
+ my_free(buf);
if (rc == HA_ERR_END_OF_FILE)
{
@@ -1735,7 +1735,7 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt)
free_root(&blobroot, MYF(0));
- my_free((char*)buf, MYF(0));
+ my_free(buf);
thd_proc_info(thd, old_proc_info);
if ((rc != HA_ERR_END_OF_FILE) || count)
diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h
index 7bb80170e87..845b50e3869 100644
--- a/storage/csv/ha_tina.h
+++ b/storage/csv/ha_tina.h
@@ -95,7 +95,7 @@ public:
~ha_tina()
{
if (chain_alloced)
- my_free(chain, 0);
+ my_free(chain);
if (file_buff)
delete file_buff;
free_root(&blobroot, MYF(0));
diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc
index 44ca2df026f..f92746c7b93 100644
--- a/storage/csv/transparent_file.cc
+++ b/storage/csv/transparent_file.cc
@@ -29,7 +29,7 @@ Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE)
Transparent_file::~Transparent_file()
{
- my_free((uchar*)buff, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buff);
}
void Transparent_file::init_buff(File filedes_arg)
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index 2fbb17e46bd..899f55a33f7 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -232,7 +232,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
error:
mysql_mutex_destroy(&share->mutex);
- my_free(share, MYF(0));
+ my_free(share);
return NULL;
}
@@ -252,7 +252,7 @@ static int free_share(EXAMPLE_SHARE *share)
my_hash_delete(&example_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
mysql_mutex_destroy(&share->mutex);
- my_free(share, MYF(0));
+ my_free(share);
}
mysql_mutex_unlock(&example_mutex);
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index 541650bd5e8..350958f8230 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -112,7 +112,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
create_info.pin_share= TRUE;
rc= heap_create(name, &create_info, &internal_share, &created_new_share);
- my_free((uchar*) create_info.keydef, MYF(0));
+ my_free(create_info.keydef);
if (rc)
goto end;
@@ -764,7 +764,7 @@ int ha_heap::create(const char *name, TABLE *table_arg,
hp_create_info.auto_increment= (create_info->auto_increment_value ?
create_info->auto_increment_value - 1 : 0);
error= heap_create(name, &hp_create_info, &internal_share, &created);
- my_free((uchar*) hp_create_info.keydef, MYF(0));
+ my_free(hp_create_info.keydef);
DBUG_ASSERT(file == 0);
return (error);
}
diff --git a/storage/heap/hp_block.c b/storage/heap/hp_block.c
index c622a9e52f8..7f6cc1ef90a 100644
--- a/storage/heap/hp_block.c
+++ b/storage/heap/hp_block.c
@@ -145,7 +145,7 @@ uchar *hp_free_level(HP_BLOCK *block, uint level, HP_PTRS *pos, uchar *last_pos)
}
if ((uchar*) pos != last_pos)
{
- my_free((uchar*) pos,MYF(0));
+ my_free(pos);
return last_pos;
}
return next_ptr; /* next memory position */
diff --git a/storage/heap/hp_close.c b/storage/heap/hp_close.c
index 49d8ec376bb..e5a826423db 100644
--- a/storage/heap/hp_close.c
+++ b/storage/heap/hp_close.c
@@ -46,6 +46,6 @@ int hp_close(register HP_INFO *info)
heap_open_list=list_delete(heap_open_list,&info->open_list);
if (!--info->s->open_count && info->s->delete_on_close)
hp_free(info->s); /* Table was deleted */
- my_free((uchar*) info,MYF(0));
+ my_free(info);
DBUG_RETURN(error);
}
diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c
index cf0f5d5ba6d..bbf649c5e46 100644
--- a/storage/heap/hp_create.c
+++ b/storage/heap/hp_create.c
@@ -189,7 +189,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
/* Must be allocated separately for rename to work */
if (!(share->name= my_strdup(name,MYF(0))))
{
- my_free((uchar*) share,MYF(0));
+ my_free(share);
goto err;
}
#ifdef THREAD
@@ -305,7 +305,7 @@ void hp_free(HP_SHARE *share)
thr_lock_delete(&share->lock);
mysql_mutex_destroy(&share->intern_lock);
#endif
- my_free((uchar*) share->name, MYF(0));
- my_free((uchar*) share, MYF(0));
+ my_free(share->name);
+ my_free(share);
return;
}
diff --git a/storage/heap/hp_rename.c b/storage/heap/hp_rename.c
index c4e8390cc43..cf0d2b2b387 100644
--- a/storage/heap/hp_rename.c
+++ b/storage/heap/hp_rename.c
@@ -33,7 +33,7 @@ int heap_rename(const char *old_name, const char *new_name)
mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(my_errno);
}
- my_free(info->name,MYF(0));
+ my_free(info->name);
info->name=name_buff;
}
mysql_mutex_unlock(&THR_LOCK_heap);
diff --git a/storage/ibmdb2i/db2i_constraints.cc b/storage/ibmdb2i/db2i_constraints.cc
index cc2821238b6..3afa12032d0 100644
--- a/storage/ibmdb2i/db2i_constraints.cc
+++ b/storage/ibmdb2i/db2i_constraints.cc
@@ -421,7 +421,7 @@ void ha_ibmdb2i::free_foreign_key_create_info(char* info)
if (info)
{
- my_free(info, MYF(0));
+ my_free(info);
}
DBUG_VOID_RETURN;
}
diff --git a/storage/ibmdb2i/db2i_conversion.cc b/storage/ibmdb2i/db2i_conversion.cc
index 9a85eb01c9b..71a30802bf9 100644
--- a/storage/ibmdb2i/db2i_conversion.cc
+++ b/storage/ibmdb2i/db2i_conversion.cc
@@ -292,7 +292,7 @@ static void get_field_default_value(Field *field,
if (iconv(iconvD, (char**)&tempIn, &ilen, &tempOut, &olen, &substitutedChars) < 0)
{
warning(current_thd, DB2I_ERR_WARN_COL_ATTRS, field->field_name);
- my_free(out, MYF(0));
+ my_free(out);
return;
}
// Now we process the converted string to represent it as
@@ -310,7 +310,7 @@ static void get_field_default_value(Field *field,
if (length > 16370)
{
warning(current_thd, DB2I_ERR_WARN_COL_ATTRS, field->field_name);
- my_free(out, MYF(0));
+ my_free(out);
return;
}
@@ -335,7 +335,7 @@ static void get_field_default_value(Field *field,
if (field->charset() == &my_charset_bin)
defaultClause.append(")");
- my_free(out, MYF(0));
+ my_free(out);
}
}
else
diff --git a/storage/ibmdb2i/db2i_file.cc b/storage/ibmdb2i/db2i_file.cc
index a16aa927527..2d83248eea7 100644
--- a/storage/ibmdb2i/db2i_file.cc
+++ b/storage/ibmdb2i/db2i_file.cc
@@ -280,12 +280,9 @@ void db2i_table::renameAssocFiles(const char* from, const char* to)
db2i_table::~db2i_table()
{
- if (blobFieldActualSizes)
- my_free(blobFieldActualSizes, MYF(0));
+ my_free(blobFieldActualSizes);
+ my_free(conversionDefinitions[toMySQL]);
- if (conversionDefinitions[toMySQL])
- my_free(conversionDefinitions[toMySQL], MYF(0));
-
if (logicalFiles)
{
for (int k = 0; k < logicalFileCount; ++k)
@@ -296,8 +293,8 @@ db2i_table::~db2i_table()
delete[] logicalFiles;
}
delete physicalFile;
-
- my_free(db2LibNameEbcdic, 0);
+
+ my_free(db2LibNameEbcdic);
}
void db2i_table::getDB2QualifiedName(char* to)
@@ -334,14 +331,14 @@ size_t db2i_table::smartFilenameToTableName(const char *in, char* out, size_t ou
if ((*cur <= 0x20) || (*cur >= 0x80))
{
strncpy(out, in, outlen);
- my_free(test, MYF(0));
+ my_free(test);
return min(outlen, strlen(out));
}
++cur;
}
strncpy(out, test, outlen);
- my_free(test, MYF(0));
+ my_free(test);
return min(outlen, strlen(out));
}
diff --git a/storage/ibmdb2i/db2i_file.h b/storage/ibmdb2i/db2i_file.h
index ff35a473b05..6cc6ae8947b 100644
--- a/storage/ibmdb2i/db2i_file.h
+++ b/storage/ibmdb2i/db2i_file.h
@@ -353,7 +353,7 @@ public:
db2i_ileBridge::getBridgeForThread()->deallocateFile(masterDefn);
if (db2FileName != (char*)db2Table->getDB2TableName(db2i_table::EBCDIC_NATIVE))
- my_free(db2FileName, MYF(0));
+ my_free(db2FileName);
}
// This is roughly equivalent to an "open". It tells ILE to allocate a descriptor
diff --git a/storage/ibmdb2i/db2i_global.h b/storage/ibmdb2i/db2i_global.h
index d201fbd8124..1cf8a9a7c61 100644
--- a/storage/ibmdb2i/db2i_global.h
+++ b/storage/ibmdb2i/db2i_global.h
@@ -131,7 +131,7 @@ void free_aligned(void* p)
{
if (likely(p))
{
- my_free(*(char**)((char*)p-sizeof(void*)), MYF(0));
+ my_free(*(char**)((char*)p-sizeof(void*)));
}
}
diff --git a/storage/ibmdb2i/db2i_ileBridge.cc b/storage/ibmdb2i/db2i_ileBridge.cc
index 68ae2c2bb72..fac98dd7107 100644
--- a/storage/ibmdb2i/db2i_ileBridge.cc
+++ b/storage/ibmdb2i/db2i_ileBridge.cc
@@ -102,7 +102,7 @@ db2i_ileBridge* db2i_ileBridge::createNewBridge(CONNECTION_HANDLE connID)
void db2i_ileBridge::destroyBridge(db2i_ileBridge* bridge)
{
bridge->freeErrorStorage();
- my_free(bridge, MYF(0));
+ my_free(bridge);
}
@@ -1306,7 +1306,7 @@ FILE_HANDLE db2i_ileBridge::PreservedHandleList::findAndRemove(const char* fileN
prev->next = next;
if (current == head)
head = next;
- my_free(current, MYF(0));
+ my_free(current);
DBUG_PRINT("db2i_ileBridge", ("Found handle %d for %s", uint32(tmp), fileName));
return tmp;
}
diff --git a/storage/ibmdb2i/db2i_ileBridge.h b/storage/ibmdb2i/db2i_ileBridge.h
index 10b9820d983..3a3ca141f69 100644
--- a/storage/ibmdb2i/db2i_ileBridge.h
+++ b/storage/ibmdb2i/db2i_ileBridge.h
@@ -320,7 +320,7 @@ public:
{
if (likely(connErrText))
{
- my_free(connErrText, MYF(0));
+ my_free(connErrText);
connErrText = NULL;
}
}
diff --git a/storage/ibmdb2i/ha_ibmdb2i.cc b/storage/ibmdb2i/ha_ibmdb2i.cc
index 81d7e59d8e3..947df8ad2fe 100644
--- a/storage/ibmdb2i/ha_ibmdb2i.cc
+++ b/storage/ibmdb2i/ha_ibmdb2i.cc
@@ -404,7 +404,7 @@ IBMDB2I_SHARE *ha_ibmdb2i::get_share(const char *table_name, TABLE *table)
error:
pthread_mutex_destroy(&share->mutex);
- my_free((uchar*) share, MYF(0));
+ my_free(share);
pthread_mutex_unlock(&ibmdb2i_mutex);
return NULL;
@@ -423,7 +423,7 @@ int ha_ibmdb2i::free_share(IBMDB2I_SHARE *share)
my_hash_delete(&ibmdb2i_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
- my_free(share, MYF(0));
+ my_free(share);
pthread_mutex_unlock(&ibmdb2i_mutex);
return 1;
}
@@ -571,9 +571,9 @@ ha_ibmdb2i::~ha_ibmdb2i()
DBUG_ASSERT(activeReferences == 0 || outstanding_start_bulk_insert);
if (indexHandles)
- my_free(indexHandles, MYF(0));
+ my_free(indexHandles);
if (indexReadSizeEstimates)
- my_free(indexReadSizeEstimates, MYF(0));
+ my_free(indexReadSizeEstimates);
cleanupBuffers();
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index b3445f86274..6b0d68241ea 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -2199,8 +2199,7 @@ innobase_init(
"InnoDB: syntax error in innodb_data_file_path");
mem_free_and_error:
srv_free_paths_and_sizes();
- my_free(internal_innobase_data_file_path,
- MYF(MY_ALLOW_ZERO_PTR));
+ my_free(internal_innobase_data_file_path);
goto error;
}
@@ -2485,8 +2484,7 @@ innobase_end(
err = 1;
}
srv_free_paths_and_sizes();
- my_free(internal_innobase_data_file_path,
- MYF(MY_ALLOW_ZERO_PTR));
+ my_free(internal_innobase_data_file_path);
mysql_mutex_destroy(&innobase_share_mutex);
mysql_mutex_destroy(&prepare_commit_mutex);
mysql_mutex_destroy(&commit_threads_m);
@@ -3439,7 +3437,7 @@ innobase_build_index_translation(
func_exit:
if (!ret) {
/* Build translation table failed. */
- my_free(index_mapping, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(index_mapping);
share->idx_trans_tbl.array_size = 0;
share->idx_trans_tbl.index_count = 0;
@@ -3673,7 +3671,7 @@ retry:
"how you can resolve the problem.\n",
norm_name);
free_share(share);
- my_free(upd_buff, MYF(0));
+ my_free(upd_buff);
my_errno = ENOENT;
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
@@ -3689,7 +3687,7 @@ retry:
"how you can resolve the problem.\n",
norm_name);
free_share(share);
- my_free(upd_buff, MYF(0));
+ my_free(upd_buff);
my_errno = ENOENT;
dict_table_decrement_handle_count(ib_table, FALSE);
@@ -3883,7 +3881,7 @@ ha_innobase::close(void)
row_prebuilt_free(prebuilt, FALSE);
- my_free(upd_buff, MYF(0));
+ my_free(upd_buff);
free_share(share);
/* Tell InnoDB server that there might be work for
@@ -6404,7 +6402,7 @@ create_index(
error = convert_error_code_to_mysql(error, flags, NULL);
- my_free(field_lengths, MYF(0));
+ my_free(field_lengths);
DBUG_RETURN(error);
}
@@ -7215,7 +7213,7 @@ innobase_drop_database(
trx = innobase_trx_allocate(thd);
#endif
error = row_drop_database_for_mysql(namebuf, trx);
- my_free(namebuf, MYF(0));
+ my_free(namebuf);
/* Flush the log to reduce probability that the .frm files and
the InnoDB data dictionary get out-of-sync if the user runs
@@ -7291,8 +7289,8 @@ innobase_rename_table(
log_buffer_flush_to_disk();
}
- my_free(norm_to, MYF(0));
- my_free(norm_from, MYF(0));
+ my_free(norm_to);
+ my_free(norm_from);
return error;
}
@@ -7455,7 +7453,7 @@ ha_innobase::records_in_range(
mem_heap_free(heap);
func_exit:
- my_free(key_val_buff2, MYF(0));
+ my_free(key_val_buff2);
prebuilt->trx->op_info = (char*)"";
@@ -8464,7 +8462,7 @@ ha_innobase::free_foreign_key_create_info(
char* str) /*!< in, own: create info string to free */
{
if (str) {
- my_free(str, MYF(0));
+ my_free(str);
}
}
@@ -9008,7 +9006,7 @@ innodb_show_status(
STRING_WITH_LEN(""), str, flen)) {
result= TRUE;
}
- my_free(str, MYF(0));
+ my_free(str);
DBUG_RETURN(FALSE);
}
@@ -9279,10 +9277,9 @@ static void free_share(INNOBASE_SHARE* share)
thr_lock_delete(&share->lock);
/* Free any memory from index translation table */
- my_free(share->idx_trans_tbl.index_mapping,
- MYF(MY_ALLOW_ZERO_PTR));
+ my_free(share->idx_trans_tbl.index_mapping);
- my_free(share, MYF(0));
+ my_free(share);
/* TODO: invoke HASH_MIGRATE if innobase_open_tables
shrinks too much */
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c
index 52ad6b11aa1..33c1e092a00 100644
--- a/storage/myisam/ft_boolean_search.c
+++ b/storage/myisam/ft_boolean_search.c
@@ -608,7 +608,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query,
return ftb;
err:
free_root(& ftb->mem_root, MYF(0));
- my_free((uchar*)ftb,MYF(0));
+ my_free(ftb);
return 0;
}
@@ -1032,7 +1032,7 @@ void ft_boolean_close_search(FT_INFO *ftb)
delete_tree(& ftb->no_dupes);
}
free_root(& ftb->mem_root, MYF(0));
- my_free((uchar*)ftb,MYF(0));
+ my_free(ftb);
}
diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c
index 5317da78ee4..7d9b13b7714 100644
--- a/storage/myisam/ft_nlq_search.c
+++ b/storage/myisam/ft_nlq_search.c
@@ -357,7 +357,7 @@ float ft_nlq_find_relevance(FT_INFO *handler,
void ft_nlq_close_search(FT_INFO *handler)
{
- my_free((uchar*)handler,MYF(0));
+ my_free(handler);
}
diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c
index 9838b15af34..1467cc56759 100644
--- a/storage/myisam/ft_stopwords.c
+++ b/storage/myisam/ft_stopwords.c
@@ -38,7 +38,7 @@ static void FT_STOPWORD_free(FT_STOPWORD *w, TREE_FREE action,
void *arg __attribute__((unused)))
{
if (action == free_free)
- my_free((uchar*) w->pos, MYF(0));
+ my_free((void*)w->pos);
}
static int ft_add_stopword(const char *w)
@@ -87,7 +87,7 @@ int ft_init_stopwords()
}
error=0;
err1:
- my_free(buffer, MYF(0));
+ my_free(buffer);
err0:
my_close(fd, MYF(MY_WME));
return error;
@@ -121,7 +121,7 @@ void ft_free_stopwords()
if (stopwords3)
{
delete_tree(stopwords3); /* purecov: inspected */
- my_free((char*) stopwords3,MYF(0));
+ my_free(stopwords3);
stopwords3=0;
}
ft_stopword_file= 0;
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 26f6a3903a8..87de58076cd 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -756,7 +756,7 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked)
recinfo must be freed.
*/
if (recinfo)
- my_free((uchar*) recinfo, MYF(0));
+ my_free(recinfo);
return my_errno;
}
@@ -1883,7 +1883,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
records, recinfo,
0, (MI_UNIQUEDEF*) 0,
&create_info, create_flags);
- my_free((uchar*) recinfo, MYF(0));
+ my_free(recinfo);
DBUG_RETURN(error);
}
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index 25267bfb9ea..13427130069 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -1369,12 +1369,12 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
printf("Lost space: %12s Linkdata: %10s\n",
llstr(empty,llbuff),llstr(link_used,llbuff2));
}
- my_free(mi_get_rec_buff_ptr(info, record), MYF(0));
+ my_free(mi_get_rec_buff_ptr(info, record));
DBUG_RETURN (error);
err:
mi_check_print_error(param,"got error: %d when reading datafile at record: %s",my_errno, llstr(records,llbuff));
err2:
- my_free(mi_get_rec_buff_ptr(info, record), MYF(0));
+ my_free(mi_get_rec_buff_ptr(info, record));
param->testflag|=T_RETRY_WITHOUT_QUICK;
DBUG_RETURN(1);
} /* chk_data_link */
@@ -1774,11 +1774,9 @@ err:
}
mi_mark_crashed_on_repair(info);
}
- my_free(mi_get_rec_buff_ptr(info, sort_param.rec_buff),
- MYF(MY_ALLOW_ZERO_PTR));
- my_free(mi_get_rec_buff_ptr(info, sort_param.record),
- MYF(MY_ALLOW_ZERO_PTR));
- my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mi_get_rec_buff_ptr(info, sort_param.rec_buff));
+ my_free(mi_get_rec_buff_ptr(info, sort_param.record));
+ my_free(sort_info.buff);
(void) end_io_cache(&param->read_cache);
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
(void) end_io_cache(&info->rec_cache);
@@ -2208,11 +2206,11 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
mysql_file_write(to, (uchar*) buff, (uint) length, param->myf_rw))
goto err;
if (buff != tmp_buff)
- my_free(buff,MYF(0));
+ my_free(buff);
DBUG_RETURN(0);
err:
if (buff != tmp_buff)
- my_free(buff,MYF(0));
+ my_free(buff);
mi_check_print_error(param,"Can't copy %s to tempfile, error %d",
type,my_errno);
DBUG_RETURN(1);
@@ -2595,13 +2593,11 @@ err:
share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS;
share->state.changed|=STATE_NOT_SORTED_PAGES;
- my_free(mi_get_rec_buff_ptr(info, sort_param.rec_buff),
- MYF(MY_ALLOW_ZERO_PTR));
- my_free(mi_get_rec_buff_ptr(info, sort_param.record),
- MYF(MY_ALLOW_ZERO_PTR));
- my_free((uchar*) sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR));
- my_free((uchar*) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR));
- my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mi_get_rec_buff_ptr(info, sort_param.rec_buff));
+ my_free(mi_get_rec_buff_ptr(info, sort_param.record));
+ my_free(sort_info.key_block);
+ my_free(sort_info.ft_buf);
+ my_free(sort_info.buff);
(void) end_io_cache(&param->read_cache);
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
if (!got_error && (param->testflag & T_UNPACK))
@@ -3142,10 +3138,10 @@ err:
mysql_mutex_destroy(&param->print_msg_mutex);
param->need_print_msg_lock= 0;
- my_free((uchar*) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR));
- my_free((uchar*) sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR));
- my_free((uchar*) sort_param,MYF(MY_ALLOW_ZERO_PTR));
- my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(sort_info.ft_buf);
+ my_free(sort_info.key_block);
+ my_free(sort_param);
+ my_free(sort_info.buff);
(void) end_io_cache(&param->read_cache);
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
if (!got_error && (param->testflag & T_UNPACK))
@@ -4551,7 +4547,7 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
if (my_errno != HA_ERR_END_OF_FILE)
{
mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
- my_free(mi_get_rec_buff_ptr(info, record), MYF(0));
+ my_free(mi_get_rec_buff_ptr(info, record));
mi_check_print_error(param,"%d when reading last record",my_errno);
DBUG_VOID_RETURN;
}
@@ -4566,7 +4562,7 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
set_if_bigger(info->s->state.auto_increment, param->auto_increment_value);
}
mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
- my_free(mi_get_rec_buff_ptr(info, record), MYF(0));
+ my_free(mi_get_rec_buff_ptr(info, record));
update_state_info(param, info, UPDATE_AUTO_INC);
DBUG_VOID_RETURN;
}
diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c
index 8ec0bf14e0a..51408ab191c 100644
--- a/storage/myisam/mi_close.c
+++ b/storage/myisam/mi_close.c
@@ -57,7 +57,7 @@ int mi_close(register MI_INFO *info)
myisam_open_list=list_delete(myisam_open_list,&info->open_list);
mysql_mutex_unlock(&share->intern_lock);
- my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mi_get_rec_buff_ptr(info, info->rec_buff));
if (flag)
{
DBUG_EXECUTE_IF("crash_before_flush_keys",
@@ -88,8 +88,8 @@ int mi_close(register MI_INFO *info)
#endif
if (share->decode_trees)
{
- my_free((uchar*) share->decode_trees,MYF(0));
- my_free((uchar*) share->decode_tables,MYF(0));
+ my_free(share->decode_trees);
+ my_free(share->decode_tables);
}
#ifdef THREAD
thr_lock_delete(&share->lock);
@@ -103,19 +103,19 @@ int mi_close(register MI_INFO *info)
}
}
#endif
- my_free((uchar*) info->s,MYF(0));
+ my_free(info->s);
}
mysql_mutex_unlock(&THR_LOCK_myisam);
if (info->ftparser_param)
{
- my_free((uchar*)info->ftparser_param, MYF(0));
+ my_free(info->ftparser_param);
info->ftparser_param= 0;
}
if (info->dfile >= 0 && mysql_file_close(info->dfile, MYF(0)))
error = my_errno;
myisam_log_command(MI_LOG_CLOSE,info,NULL,0,error);
- my_free((uchar*) info,MYF(0));
+ my_free(info);
if (error)
{
diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c
index 3db03e23637..c415264cd98 100644
--- a/storage/myisam/mi_create.c
+++ b/storage/myisam/mi_create.c
@@ -834,7 +834,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
mysql_mutex_unlock(&THR_LOCK_myisam);
if (mysql_file_close(file, MYF(0)))
goto err;
- my_free((char*) rec_per_key_part,MYF(0));
+ my_free(rec_per_key_part);
DBUG_RETURN(0);
err:
@@ -860,7 +860,7 @@ err:
MY_UNPACK_FILENAME | MY_APPEND_EXT),
MYF(0));
}
- my_free((char*) rec_per_key_part, MYF(0));
+ my_free(rec_per_key_part);
DBUG_RETURN(my_errno=save_errno); /* return the fatal errno */
}
diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
index 02a8f21e3e2..59b895b5e64 100644
--- a/storage/myisam/mi_dynrec.c
+++ b/storage/myisam/mi_dynrec.c
@@ -44,7 +44,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
#undef my_alloca
#undef my_afree
#define my_alloca(A) my_malloc((A),MYF(0))
-#define my_afree(A) my_free((A),MYF(0))
+#define my_afree(A) my_free((A))
#endif
/* Interface function from MI_INFO */
@@ -1575,7 +1575,7 @@ int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def,
error=mi_unique_comp(def, record, old_record, def->null_are_equal);
if (info->s->base.blobs)
{
- my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mi_get_rec_buff_ptr(info, info->rec_buff));
info->rec_buff=rec_buff;
}
my_afree(old_record);
diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c
index 1d877748b31..014cf1c5a2c 100644
--- a/storage/myisam/mi_open.c
+++ b/storage/myisam/mi_open.c
@@ -676,7 +676,7 @@ err:
mi_report_error(save_errno, name);
switch (errpos) {
case 6:
- my_free((uchar*) m_info,MYF(0));
+ my_free(m_info);
/* fall through */
case 5:
(void) mysql_file_close(info.dfile, MYF(0));
@@ -684,7 +684,7 @@ err:
break; /* Don't remove open table */
/* fall through */
case 4:
- my_free((uchar*) share,MYF(0));
+ my_free(share);
/* fall through */
case 3:
if (! lock_error)
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index 580c58e6ea1..0ba495fdd68 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -298,9 +298,9 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
err3:
my_errno=HA_ERR_WRONG_IN_RECORD;
err2:
- my_free((uchar*) share->decode_tables,MYF(0));
+ my_free(share->decode_tables);
err1:
- my_free((uchar*) share->decode_trees,MYF(0));
+ my_free(share->decode_trees);
err0:
DBUG_RETURN(1);
}
diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c
index ae45014eab5..31537f7054b 100644
--- a/storage/myisam/mi_preload.c
+++ b/storage/myisam/mi_preload.c
@@ -113,11 +113,11 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
}
while (pos != key_file_length);
- my_free((char*) buff, MYF(0));
+ my_free(buff);
DBUG_RETURN(0);
err:
- my_free((char*) buff, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buff);
DBUG_RETURN(my_errno= errno);
}
diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c
index 63525b08820..60b16d5549e 100644
--- a/storage/myisam/mi_test2.c
+++ b/storage/myisam/mi_test2.c
@@ -21,9 +21,6 @@
#ifdef DBUG_OFF
#undef DBUG_OFF
#endif
-#ifndef SAFEMALLOC
-#define SAFEMALLOC
-#endif
#include "myisamdef.h"
#include <m_ctype.h>
#include <my_bit.h>
@@ -856,7 +853,7 @@ reads: %10lu\n",
}
end_key_cache(dflt_key_cache,1);
if (blob_buffer)
- my_free(blob_buffer,MYF(0));
+ my_free(blob_buffer);
my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO);
return(0);
err:
diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c
index 5b46db111b3..f2d43585eef 100644
--- a/storage/myisam/mi_write.c
+++ b/storage/myisam/mi_write.c
@@ -286,7 +286,7 @@ int _mi_ck_write_btree(register MI_INFO *info, uint keynr, uchar *key,
if (!error)
error= _mi_ft_convert_to_ft2(info, keynr, key);
delete_dynamic(info->ft1_to_ft2);
- my_free((uchar*)info->ft1_to_ft2, MYF(0));
+ my_free(info->ft1_to_ft2);
info->ft1_to_ft2=0;
}
DBUG_RETURN(error);
@@ -1045,7 +1045,7 @@ void mi_end_bulk_insert(MI_INFO *info)
delete_tree(& info->bulk_insert[i]);
}
}
- my_free((void *)info->bulk_insert, MYF(0));
+ my_free(info->bulk_insert);
info->bulk_insert=0;
}
}
diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c
index 11ec52fd123..0e32dc59d89 100644
--- a/storage/myisam/myisamchk.c
+++ b/storage/myisam/myisamchk.c
@@ -1629,11 +1629,10 @@ err:
{
my_afree((uchar*) temp_buff);
}
- my_free(mi_get_rec_buff_ptr(info, sort_param.record),
- MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mi_get_rec_buff_ptr(info, sort_param.record));
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
(void) end_io_cache(&info->rec_cache);
- my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(sort_info.buff);
sort_info.buff=0;
share->state.sortkey=sort_key;
DBUG_RETURN(flush_blocks(param, share->key_cache, share->kfile) |
@@ -1673,7 +1672,6 @@ static int sort_record_index(MI_SORT_PARAM *sort_param,MI_INFO *info,
endpos=buff+used_length;
for ( ;; )
{
- _sanity(__FILE__,__LINE__);
if (nod_flag)
{
next_page=_mi_kpos(nod_flag,keypos);
@@ -1689,7 +1687,6 @@ static int sort_record_index(MI_SORT_PARAM *sort_param,MI_INFO *info,
new_file, update_index))
goto err;
}
- _sanity(__FILE__,__LINE__);
if (keypos >= endpos ||
(key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&keypos,lastkey))
== 0)
diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c
index 089e3480da6..1733d7140cd 100644
--- a/storage/myisam/myisamlog.c
+++ b/storage/myisam/myisamlog.c
@@ -616,7 +616,7 @@ static int examine_log(char * file_name, char **table_names)
}
}
}
- my_free(buff,MYF(0));
+ my_free(buff);
break;
case MI_LOG_LOCK:
if (my_b_read(&cache,(uchar*) head,sizeof(lock_command)))
@@ -683,12 +683,12 @@ static int read_string(IO_CACHE *file, register uchar* *to, register uint length
DBUG_ENTER("read_string");
if (*to)
- my_free((uchar*) *to,MYF(0));
+ my_free(*to);
if (!(*to= (uchar*) my_malloc(length+1,MYF(MY_WME))) ||
my_b_read(file,(uchar*) *to,length))
{
if (*to)
- my_free(*to,MYF(0));
+ my_free(*to);
*to= 0;
DBUG_RETURN(1);
}
@@ -759,10 +759,10 @@ static void file_info_free(struct file_info *fileinfo)
if (!fileinfo->closed)
(void) mi_close(fileinfo->isam);
if (fileinfo->record)
- my_free(fileinfo->record,MYF(0));
+ my_free(fileinfo->record);
}
- my_free(fileinfo->name,MYF(0));
- my_free(fileinfo->show_name,MYF(0));
+ my_free(fileinfo->name);
+ my_free(fileinfo->show_name);
DBUG_VOID_RETURN;
}
diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c
index 18810a60166..d4997a2bcbb 100644
--- a/storage/myisam/myisampack.c
+++ b/storage/myisam/myisampack.c
@@ -486,7 +486,7 @@ static my_bool open_isam_files(PACK_MRG_INFO *mrg, char **names, uint count)
error:
while (i--)
mi_close(mrg->file[i]);
- my_free((uchar*) mrg->file,MYF(0));
+ my_free(mrg->file);
return 1;
}
@@ -534,10 +534,10 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
my_write(join_isam_file,buff,length,
MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL)))
{
- my_free(buff,MYF(0));
+ my_free(buff);
goto err;
}
- my_free(buff,MYF(0));
+ my_free(buff);
(void) fn_format(new_name,result_table,"",MI_NAME_DEXT,2);
}
else if (!tmp_dir[0])
@@ -564,7 +564,6 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
}
trees=fields=share->base.fields;
huff_counts=init_huff_count(isam_file,mrg->records);
- QUICK_SAFEMALLOC;
/*
Read the whole data file(s) for statistics.
@@ -574,7 +573,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
printf("- Calculating statistics\n");
if (get_statistic(mrg,huff_counts))
goto err;
- NORMAL_SAFEMALLOC;
+
old_length=0;
for (i=0; i < mrg->count ; i++)
old_length+= (mrg->file[i]->s->state.state.data_file_length -
@@ -857,11 +856,11 @@ static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees, uint trees,
for (i=0 ; i < trees ; i++)
{
if (huff_trees[i].element_buffer)
- my_free((uchar*) huff_trees[i].element_buffer,MYF(0));
+ my_free(huff_trees[i].element_buffer);
if (huff_trees[i].code)
- my_free((uchar*) huff_trees[i].code,MYF(0));
+ my_free(huff_trees[i].code);
}
- my_free((uchar*) huff_trees,MYF(0));
+ my_free(huff_trees);
}
if (huff_counts)
{
@@ -869,11 +868,11 @@ static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees, uint trees,
{
if (huff_counts[i].tree_buff)
{
- my_free((uchar*) huff_counts[i].tree_buff,MYF(0));
+ my_free(huff_counts[i].tree_buff);
delete_tree(&huff_counts[i].int_tree);
}
}
- my_free((uchar*) huff_counts,MYF(0));
+ my_free(huff_counts);
}
delete_queue(&queue); /* This is safe to free */
return;
@@ -977,7 +976,7 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
count->int_tree.elements_in_tree > 1))
{
delete_tree(&count->int_tree);
- my_free(count->tree_buff,MYF(0));
+ my_free(count->tree_buff);
count->tree_buff=0;
}
else
@@ -1374,12 +1373,12 @@ static void check_counts(HUFF_COUNTS *huff_counts, uint trees,
}
else
{
- my_free((uchar*) huff_counts->tree_buff,MYF(0));
+ my_free(huff_counts->tree_buff);
delete_tree(&huff_counts->int_tree);
huff_counts->tree_buff=0;
}
if (tree.element_buffer)
- my_free((uchar*) tree.element_buffer,MYF(0));
+ my_free(tree.element_buffer);
}
if (huff_counts->pack_type & PACK_TYPE_SPACE_FIELDS)
space_fields++;
@@ -1496,8 +1495,8 @@ static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts, uint trees)
if (make_huff_tree(huff_tree+tree,huff_counts+tree))
{
while (tree--)
- my_free((uchar*) huff_tree[tree].element_buffer,MYF(0));
- my_free((uchar*) huff_tree,MYF(0));
+ my_free(huff_tree[tree].element_buffer);
+ my_free(huff_tree);
DBUG_RETURN(0);
}
}
@@ -1907,7 +1906,7 @@ static uint join_same_trees(HUFF_COUNTS *huff_counts, uint trees)
{
memcpy_fixed((uchar*) i->counts,(uchar*) count.counts,
sizeof(count.counts[0])*256);
- my_free((uchar*) j->tree->element_buffer,MYF(0));
+ my_free(j->tree->element_buffer);
j->tree->element_buffer=0;
j->tree=i->tree;
bmove((uchar*) i->counts,(uchar*) count.counts,
@@ -2913,7 +2912,7 @@ static int flush_buffer(ulong neaded_length)
static void end_file_buffer(void)
{
- my_free((uchar*) file_buffer.buffer,MYF(0));
+ my_free(file_buffer.buffer);
}
/* output `bits` low bits of `value' */
@@ -3117,7 +3116,7 @@ static int mrg_close(PACK_MRG_INFO *mrg)
for (i=0 ; i < mrg->count ; i++)
error|=mi_close(mrg->file[i]);
if (mrg->free_file)
- my_free((uchar*) mrg->file,MYF(0));
+ my_free(mrg->file);
return error;
}
@@ -3180,7 +3179,7 @@ static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count)
*/
if (huff_counts->tree_buff)
{
- my_free((uchar*) huff_counts->tree_buff, MYF(0));
+ my_free(huff_counts->tree_buff);
delete_tree(&huff_counts->int_tree);
huff_counts->tree_buff= NULL;
DBUG_PRINT("fakebigcodes", ("freed distinct column values"));
diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c
index 410badd3145..32cf1fd924d 100644
--- a/storage/myisam/rt_index.c
+++ b/storage/myisam/rt_index.c
@@ -972,7 +972,7 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length)
goto err1;
}
if (ReinsertList.pages)
- my_free((uchar*) ReinsertList.pages, MYF(0));
+ my_free(ReinsertList.pages);
/* check for redundant root (not leaf, 1 child) and eliminate */
if ((old_root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR)
diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c
index 539630899f4..a824de8c9fb 100644
--- a/storage/myisam/sort.c
+++ b/storage/myisam/sort.c
@@ -162,7 +162,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer,
maxbuffer/2))
{
- my_free((uchar*) sort_keys,MYF(0));
+ my_free(sort_keys);
sort_keys= 0;
}
else
@@ -242,8 +242,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
error =0;
err:
- if (sort_keys)
- my_free((uchar*) sort_keys,MYF(0));
+ my_free(sort_keys);
delete_dynamic(&buffpek);
close_cached_file(&tempfile);
close_cached_file(&tempfile_for_exceptions);
@@ -382,7 +381,7 @@ pthread_handler_t thr_find_all_keys(void *arg)
if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
maxbuffer, maxbuffer/2))
{
- my_free((uchar*) sort_keys,MYF(0));
+ my_free(sort_keys);
sort_keys= (uchar **) NULL; /* for err: label */
}
else
@@ -451,8 +450,7 @@ pthread_handler_t thr_find_all_keys(void *arg)
err:
DBUG_PRINT("error", ("got some error"));
sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */
- if (sort_keys)
- my_free((uchar*) sort_keys,MYF(0));
+ my_free(sort_keys);
sort_param->sort_keys= 0;
delete_dynamic(& sort_param->buffpek);
close_cached_file(&sort_param->tempfile);
@@ -509,8 +507,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
if (!sinfo->sort_keys)
{
got_error=1;
- my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff),
- MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff));
continue;
}
if (!got_error)
@@ -528,9 +525,8 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
got_error=1;
}
}
- my_free((uchar*) sinfo->sort_keys,MYF(0));
- my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff),
- MYF(MY_ALLOW_ZERO_PTR));
+ my_free(sinfo->sort_keys);
+ my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff));
sinfo->sort_keys=0;
}
@@ -638,7 +634,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
sinfo->notnull : NULL,
(ulonglong) info->state->records);
}
- my_free((uchar*) mergebuf,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mergebuf);
DBUG_RETURN(got_error);
}
#endif /* THREAD */
@@ -1057,7 +1053,7 @@ flush_ft_buf(MI_SORT_PARAM *info)
if (info->sort_info->ft_buf)
{
err=sort_ft_buf_flush(info);
- my_free((uchar*)info->sort_info->ft_buf, MYF(0));
+ my_free(info->sort_info->ft_buf);
info->sort_info->ft_buf=0;
}
return err;
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 67b81225b13..bf34bf538a1 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -831,7 +831,7 @@ int ha_myisammrg::attach_children(void)
error= HA_ERR_WRONG_MRG_TABLE_DEF;
if (!(this->test_if_locked & HA_OPEN_FOR_REPAIR))
{
- my_free((uchar*) recinfo, MYF(0));
+ my_free(recinfo);
goto err;
}
/* purecov: begin inspected */
@@ -839,7 +839,7 @@ int ha_myisammrg::attach_children(void)
/* purecov: end */
}
}
- my_free((uchar*) recinfo, MYF(0));
+ my_free(recinfo);
if (error == HA_ERR_WRONG_MRG_TABLE_DEF)
goto err; /* purecov: inspected */
diff --git a/storage/myisammrg/myrg_close.c b/storage/myisammrg/myrg_close.c
index 45e0a82913a..066a09cadbc 100644
--- a/storage/myisammrg/myrg_close.c
+++ b/storage/myisammrg/myrg_close.c
@@ -53,13 +53,13 @@ int myrg_close(MYRG_INFO *info)
}
}
else
- my_free((uchar*) info->rec_per_key_part, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(info->rec_per_key_part);
delete_queue(&info->by_key);
mysql_mutex_lock(&THR_LOCK_open);
myrg_open_list=list_delete(myrg_open_list,&info->open_list);
mysql_mutex_unlock(&THR_LOCK_open);
mysql_mutex_destroy(&info->mutex);
- my_free((uchar*) info,MYF(0));
+ my_free(info);
if (error)
{
DBUG_RETURN(my_errno=error);
diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c
index 915680ab64c..e4793ffe672 100644
--- a/storage/myisammrg/myrg_open.c
+++ b/storage/myisammrg/myrg_open.c
@@ -186,7 +186,7 @@ err:
case 3:
while (files)
(void) mi_close(m_info->open_tables[--files].table);
- my_free((char*) m_info,MYF(0));
+ my_free(m_info);
/* Fall through */
case 2:
end_io_cache(&file);
@@ -339,7 +339,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
save_errno= my_errno;
switch (errpos) {
case 3:
- my_free((char*) m_info, MYF(0));
+ my_free(m_info);
/* Fall through */
case 2:
end_io_cache(&file_cache);
@@ -422,7 +422,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
key_parts= myisam->s->base.key_parts;
if (*need_compat_check && m_info->rec_per_key_part)
{
- my_free((char *) m_info->rec_per_key_part, MYF(0));
+ my_free(m_info->rec_per_key_part);
m_info->rec_per_key_part= NULL;
}
if (!m_info->rec_per_key_part)
@@ -491,7 +491,7 @@ err:
save_errno= my_errno;
switch (errpos) {
case 1:
- my_free((char*) m_info->rec_per_key_part, MYF(0));
+ my_free(m_info->rec_per_key_part);
m_info->rec_per_key_part= NULL;
}
mysql_mutex_unlock(&m_info->mutex);
diff --git a/storage/ndb/config/win-lib.am b/storage/ndb/config/win-lib.am
index 05ac1ec8a40..1e7bbfae19b 100644
--- a/storage/ndb/config/win-lib.am
+++ b/storage/ndb/config/win-lib.am
@@ -68,7 +68,7 @@ LIB32=xilink6.exe -lib
# PROP Intermediate_Dir "debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /Gf /D "WIN32" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /FD /c
+# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /Gf /D "WIN32" /D "_DEBUG" /D "SAFE_MUTEX" /D "_WINDOWS" /FD /c
# ADD BASE CPP @includes@
# ADD CPP @includes@
# SUBTRACT CPP /YX
diff --git a/storage/ndb/config/win-prg.am b/storage/ndb/config/win-prg.am
index 70c19a70c6d..5d56d79c41e 100644
--- a/storage/ndb/config/win-prg.am
+++ b/storage/ndb/config/win-prg.am
@@ -71,7 +71,7 @@ LINK32=xilink6.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "NDB_WIN32" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /D "NDB_WIN32" /I "../include" /I "../regex" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c
+# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /D "NDB_WIN32" /I "../include" /I "../regex" /I "../zlib" /D "_DEBUG" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c
# ADD BASE CPP @includes@
# ADD CPP @includes@
# SUBTRACT CPP /Fr /YX
diff --git a/storage/ndb/include/util/NdbAutoPtr.hpp b/storage/ndb/include/util/NdbAutoPtr.hpp
index 5210fbc6dde..f11b8f0d5bc 100644
--- a/storage/ndb/include/util/NdbAutoPtr.hpp
+++ b/storage/ndb/include/util/NdbAutoPtr.hpp
@@ -51,8 +51,8 @@ class My_auto_ptr {
T * m_obj;
public:
My_auto_ptr(T * obj = 0){ m_obj = obj;}
- void reset(T * obj = 0) { if (m_obj) my_free(m_obj,MYF(0)); m_obj = obj; }
- ~My_auto_ptr() { if (m_obj) my_free(m_obj,MYF(0));}
+ void reset(T * obj = 0) { if (m_obj) my_free(m_obj); m_obj = obj; }
+ ~My_auto_ptr() { if (m_obj) my_free(m_obj);}
};
#endif
diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp
index 662e5c22f48..78c767c31c6 100644
--- a/storage/ndb/src/mgmapi/mgmapi.cpp
+++ b/storage/ndb/src/mgmapi/mgmapi.cpp
@@ -212,7 +212,7 @@ extern "C"
void
ndb_mgm_set_name(NdbMgmHandle handle, const char *name)
{
- my_free(handle->m_name, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(handle->m_name);
handle->m_name= my_strdup(name, MYF(MY_WME));
}
@@ -278,10 +278,10 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
}
#endif
(*handle)->cfg.~LocalConfig();
- my_free((*handle)->m_name, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((*handle)->m_name);
if ((*handle)->m_bindaddress)
free((*handle)->m_bindaddress);
- my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(* handle);
* handle = 0;
DBUG_VOID_RETURN;
}
diff --git a/storage/ndb/src/mgmapi/ndb_logevent.cpp b/storage/ndb/src/mgmapi/ndb_logevent.cpp
index fbf026fd79d..c372f852144 100644
--- a/storage/ndb/src/mgmapi/ndb_logevent.cpp
+++ b/storage/ndb/src/mgmapi/ndb_logevent.cpp
@@ -82,7 +82,7 @@ void ndb_mgm_destroy_logevent_handle(NdbLogEventHandle * h)
if ( *h )
close((*h)->socket);
- my_free((char*)* h,MYF(MY_ALLOW_ZERO_PTR));
+ my_free(* h);
* h = 0;
}
diff --git a/storage/ndb/test/ndbapi/testIndexStat.cpp b/storage/ndb/test/ndbapi/testIndexStat.cpp
index 0e15cdd80d1..559fade3132 100644
--- a/storage/ndb/test/ndbapi/testIndexStat.cpp
+++ b/storage/ndb/test/ndbapi/testIndexStat.cpp
@@ -404,9 +404,9 @@ static void
freekeys()
{
if (g_keys != 0)
- my_free((char*)g_keys, MYF(0));
+ my_free(g_keys);
if (g_sortkeys != 0)
- my_free((char*)g_sortkeys, MYF(0));
+ my_free(g_sortkeys);
g_keys = 0;
g_sortkeys = 0;
}
@@ -896,7 +896,7 @@ static void
freeranges()
{
if (g_ranges != 0)
- my_free((char*)g_ranges, MYF(0));
+ my_free(g_ranges);
g_ranges = 0;
}
diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp
index e8e8d584f09..f63cbdd2aa2 100644
--- a/storage/ndb/tools/restore/consumer_restore.cpp
+++ b/storage/ndb/tools/restore/consumer_restore.cpp
@@ -449,13 +449,13 @@ bool BackupRestore::translate_frm(NdbDictionary::Table *table)
}
if (map_in_frm(new_data, (const char*)data, data_len, &new_data_len))
{
- my_free(new_data, MYF(0));
+ my_free(new_data);
DBUG_RETURN(TRUE);
}
if (packfrm((uchar*) new_data, new_data_len,
&new_pack_data, &new_pack_len))
{
- my_free(new_data, MYF(0));
+ my_free(new_data);
DBUG_RETURN(TRUE);
}
table->setFrm(new_pack_data, new_pack_len);
diff --git a/storage/perfschema/pfs.cc b/storage/perfschema/pfs.cc
index f5901540ab0..3cd637ffa66 100644
--- a/storage/perfschema/pfs.cc
+++ b/storage/perfschema/pfs.cc
@@ -1009,7 +1009,7 @@ void* pfs_spawn_thread(void *arg)
*/
user_start_routine= typed_arg->m_user_start_routine;
user_arg= typed_arg->m_user_arg;
- my_free(typed_arg, MYF(0));
+ my_free(typed_arg);
/* Then, execute the user code for this thread. */
(*user_start_routine)(user_arg);
@@ -1037,7 +1037,7 @@ static int spawn_thread_v1(PSI_thread_key key,
int result= pthread_create(thread, attr, pfs_spawn_thread, psi_arg);
if (unlikely(result != 0))
- my_free(psi_arg, MYF(0));
+ my_free(psi_arg);
return result;
}
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index a490cac054d..1fd2c45cb63 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -19519,7 +19519,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)
@@ -19676,7 +19676,7 @@ int main(int argc, char **argv)
print_test_output();
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();
diff --git a/tests/thread_test.c b/tests/thread_test.c
index def133f4a3f..1a3dd60c1fd 100644
--- a/tests/thread_test.c
+++ b/tests/thread_test.c
@@ -150,7 +150,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'p':
if (argument)
{
- my_free(password, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(password);
password= my_strdup(argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
}
diff --git a/unittest/mysys/CMakeLists.txt b/unittest/mysys/CMakeLists.txt
index 3bf23df6066..56a3d67f25f 100644
--- a/unittest/mysys/CMakeLists.txt
+++ b/unittest/mysys/CMakeLists.txt
@@ -27,6 +27,6 @@ MACRO (MY_ADD_TEST name)
ENDMACRO()
-FOREACH(testname bitmap base64 my_vsnprintf my_atomic my_rdtsc lf)
+FOREACH(testname bitmap base64 my_vsnprintf my_atomic my_rdtsc lf my_malloc)
MY_ADD_TEST(${testname})
ENDFOREACH()
diff --git a/unittest/mysys/Makefile.am b/unittest/mysys/Makefile.am
index 25b30e331b0..64d2749987e 100644
--- a/unittest/mysys/Makefile.am
+++ b/unittest/mysys/Makefile.am
@@ -23,7 +23,7 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/strings/libmystrings.a
-noinst_PROGRAMS = bitmap-t base64-t lf-t my_rdtsc-t my_vsnprintf-t
+noinst_PROGRAMS = bitmap-t base64-t lf-t my_rdtsc-t my_vsnprintf-t my_malloc-t
if NEED_THREAD
# my_atomic-t is used to check thread functions, so it is safe to
diff --git a/unittest/mysys/my_malloc-t.c b/unittest/mysys/my_malloc-t.c
new file mode 100644
index 00000000000..00cac0d21b7
--- /dev/null
+++ b/unittest/mysys/my_malloc-t.c
@@ -0,0 +1,43 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#include <my_global.h>
+#include <my_sys.h>
+#include "tap.h"
+
+int main(void)
+{
+ void *p;
+ MY_INIT("my_malloc-t");
+
+ plan(4);
+
+ p= my_malloc(0, MYF(0));
+ ok(p != NULL, "Zero-sized block allocation.");
+
+ p= my_realloc(p, 32, MYF(0));
+ ok(p != NULL, "Reallocated zero-sized block.");
+
+ p= my_realloc(p, 16, MYF(0));
+ ok(p != NULL, "Trimmed block.");
+
+ my_free(p);
+ p= NULL;
+
+ ok((my_free(p), 1), "Free NULL pointer.");
+
+ return exit_status();
+}
+
diff --git a/vio/test-ssl.c b/vio/test-ssl.c
index 855dc5fbb3e..25a394a1ce0 100644
--- a/vio/test-ssl.c
+++ b/vio/test-ssl.c
@@ -106,8 +106,8 @@ main(int argc, char** argv)
child_pid = fork();
if (child_pid==-1) {
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
fatal_error("fork");
}
if (child_pid==0)
@@ -116,28 +116,28 @@ main(int argc, char** argv)
char xbuf[100];
int r = vio_read(client_vio,xbuf, sizeof(xbuf));
if (r<=0) {
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
fatal_error("client:SSL_read");
}
xbuf[r] = 0;
printf("client:got %s\n", xbuf);
- my_free((uchar*)client_vio,MYF(0));
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(client_vio);
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
}
else
{
const char* s = "Huhuhuh";
int r = vio_write(server_vio,(uchar*)s, strlen(s));
if (r<=0) {
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
fatal_error("server:SSL_write");
}
- my_free((uchar*)server_vio,MYF(0));
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(server_vio);
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
}
return 0;
}
diff --git a/vio/test-sslclient.c b/vio/test-sslclient.c
index e1b8461397b..643dcbf2c8e 100644
--- a/vio/test-sslclient.c
+++ b/vio/test-sslclient.c
@@ -84,13 +84,13 @@ main( int argc __attribute__((unused)),
sslconnect(ssl_connector,client_vio,60L);
err = vio_read(client_vio,xbuf, sizeof(xbuf));
if (err<=0) {
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(ssl_connector);
fatal_error("client:SSL_read");
}
xbuf[err] = 0;
printf("client:got %s\n", xbuf);
- my_free((uchar*)client_vio,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(client_vio);
+ my_free(ssl_connector);
return 0;
}
#else /* HAVE_OPENSSL */
diff --git a/vio/test-sslserver.c b/vio/test-sslserver.c
index f55b5bae53a..3123a4def2c 100644
--- a/vio/test-sslserver.c
+++ b/vio/test-sslserver.c
@@ -139,12 +139,12 @@ main(int argc __attribute__((unused)), char** argv)
#if 0
if (err<=0) {
- my_free((uchar*)ssl_acceptor,MYF(0));
+ my_free(ssl_acceptor);
fatal_error("server:SSL_write");
}
#endif /* 0 */
- my_free((uchar*)ssl_acceptor,MYF(0));
+ my_free(ssl_acceptor);
return 0;
}
#else /* HAVE_OPENSSL */
diff --git a/vio/vio.c b/vio/vio.c
index 73dd68b938f..67704a56b22 100644
--- a/vio/vio.c
+++ b/vio/vio.c
@@ -164,7 +164,7 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
void vio_reset(Vio* vio, enum enum_vio_type type,
my_socket sd, HANDLE hPipe, uint flags)
{
- my_free(vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(vio->read_buffer);
vio_init(vio, type, sd, hPipe, flags);
}
@@ -263,8 +263,8 @@ void vio_delete(Vio* vio)
if (vio->type != VIO_CLOSED)
vio->vioclose(vio);
- my_free((uchar*) vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR));
- my_free((uchar*) vio,MYF(0));
+ my_free(vio->read_buffer);
+ my_free(vio);
}
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index d0a0a69f70b..2a38bbdfd57 100644
--- a/vio/viosslfactories.c
+++ b/vio/viosslfactories.c
@@ -224,7 +224,7 @@ new_VioSSLFd(const char *key_file, const char *cert_file,
*error= SSL_INITERR_MEMFAIL;
DBUG_PRINT("error", ("%s", sslGetErrString(*error)));
report_errors();
- my_free((void*)ssl_fd,MYF(0));
+ my_free(ssl_fd);
DBUG_RETURN(0);
}
@@ -240,7 +240,7 @@ new_VioSSLFd(const char *key_file, const char *cert_file,
DBUG_PRINT("error", ("%s", sslGetErrString(*error)));
report_errors();
SSL_CTX_free(ssl_fd->ssl_context);
- my_free((void*)ssl_fd,MYF(0));
+ my_free(ssl_fd);
DBUG_RETURN(0);
}
@@ -254,7 +254,7 @@ new_VioSSLFd(const char *key_file, const char *cert_file,
DBUG_PRINT("error", ("%s", sslGetErrString(*error)));
report_errors();
SSL_CTX_free(ssl_fd->ssl_context);
- my_free((void*)ssl_fd,MYF(0));
+ my_free(ssl_fd);
DBUG_RETURN(0);
}
}
@@ -264,7 +264,7 @@ new_VioSSLFd(const char *key_file, const char *cert_file,
DBUG_PRINT("error", ("vio_set_cert_stuff failed"));
report_errors();
SSL_CTX_free(ssl_fd->ssl_context);
- my_free((void*)ssl_fd,MYF(0));
+ my_free(ssl_fd);
DBUG_RETURN(0);
}
@@ -344,6 +344,6 @@ new_VioSSLAcceptorFd(const char *key_file, const char *cert_file,
void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd)
{
SSL_CTX_free(fd->ssl_context);
- my_free((uchar*) fd, MYF(0));
+ my_free(fd);
}
#endif /* HAVE_OPENSSL */
diff --git a/vio/viotest-ssl.c b/vio/viotest-ssl.c
index b8abbac4ed6..5c68e861d2a 100644
--- a/vio/viotest-ssl.c
+++ b/vio/viotest-ssl.c
@@ -106,8 +106,8 @@ int main(int argc, char **argv)
child_pid = fork();
if (child_pid==-1)
{
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
fatal_error("fork");
}
if (child_pid==0)
@@ -116,15 +116,15 @@ int main(int argc, char **argv)
char xbuf[100];
int r = vio_ssl_read(client_vio,xbuf, sizeof(xbuf));
if (r<=0) {
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
fatal_error("client:SSL_read");
}
xbuf[r] = 0;
printf("client:got %s\n", xbuf);
- my_free((uchar*)client_vio,MYF(0));
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(client_vio);
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
sleep(1);
}
else
@@ -132,13 +132,13 @@ int main(int argc, char **argv)
const char* s = "Huhuhuh";
int r = vio_ssl_write(server_vio,(uchar*)s, strlen(s));
if (r<=0) {
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
fatal_error("server:SSL_write");
}
- my_free((uchar*)server_vio,MYF(0));
- my_free((uchar*)ssl_acceptor,MYF(0));
- my_free((uchar*)ssl_connector,MYF(0));
+ my_free(server_vio);
+ my_free(ssl_acceptor);
+ my_free(ssl_connector);
sleep(1);
}
return 0;