List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:July 1 2010 3:13pm
Subject:bzr commit into mysql-trunk-bugfixing branch (davi:3085) Bug#34043
View as plain text  
# At a local mysql-trunk-bugfixing repository of davi

 3085 Davi Arnaut	2010-07-01
      Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
      
      Essentially, the problem is that safemalloc is excruciatingly
      slow as it checks all allocated blocks for overrun at each
      memory management primitive, yielding a almost exponential
      slowdown for the memory management functions (malloc, realloc,
      free). The overrun check basically consists of verifying some
      bytes of a block for certain magic keys, which catches some
      simple forms of overrun. Another minor problem is violation
      of aliasing rules and that its own internal list of blocks
      is prone to corruption.
      
      Given the magnitude of memory debuggers available nowadays,
      especially those that are provided with the platform malloc
      implementation, maintenance of a in-house and largely obsolete
      memory debugger becomes a burden that is not worth the effort
      due to its slowness and lack of support for detecting more
      common forms of heap corruption.
      
      Since there are third-party tools (such as valgrind, malloc
      debug, etc) that can provide the same functionality at a
      lower or comparable performance cost, the solution is to
      simply remove safemalloc.
      
      The removal of safemalloc also allows a simplification of the
      malloc wrappers, removing quite a bit of kludge: redefinition
      of my_malloc, my_free and the removal of the unused second
      argument of my_free. Since my_free always check whether the
      supplied pointer is null, redudant checks are also removed.
     @ client/mysqldump.c
        Pass my_free directly as its signature is compatible with the
        callback type -- which wasn't the case for free_table_ent.

    removed:
      dbug/sanity.c
      mysql-test/t/mysql-bug45236-master.opt
      mysys/safemalloc.c
    modified:
      BUILD/SETUP.sh
      BUILD/build_mccge.sh
      BUILD/compile-ia64-debug-max
      CMakeLists.txt
      client/completion_hash.cc
      client/mysql.cc
      client/mysqladmin.cc
      client/mysqlbinlog.cc
      client/mysqlcheck.c
      client/mysqldump.c
      client/mysqlimport.c
      client/mysqlshow.c
      client/mysqlslap.c
      client/mysqltest.cc
      client/readline.cc
      client/sql_string.h
      configure.in
      dbug/CMakeLists.txt
      dbug/Makefile.am
      dbug/dbug.c
      dbug/user.r
      extra/comp_err.c
      extra/my_print_defaults.c
      extra/replace.c
      include/hash.h
      include/lf.h
      include/my_global.h
      include/my_list.h
      include/my_nosys.h
      include/my_sys.h
      include/mysql/psi/mysql_file.h
      libmysql/Makefile.am
      libmysql/Makefile.shared
      libmysql/libmysql.c
      libmysqld/lib_sql.cc
      libmysqld/libmysqld.c
      mysql-test/include/mysqld--help.inc
      mysql-test/lib/v1/mtr_report.pl
      mysql-test/lib/v1/mysql-test-run.pl
      mysql-test/mysql-stress-test.pl
      mysql-test/mysql-test-run.pl
      mysql-test/t/bug46080-master.opt
      mysys/CMakeLists.txt
      mysys/Makefile.am
      mysys/array.c
      mysys/charset.c
      mysys/default_modify.c
      mysys/hash.c
      mysys/lf_alloc-pin.c
      mysys/lf_dynarray.c
      mysys/lf_hash.c
      mysys/list.c
      mysys/mf_cache.c
      mysys/mf_iocache.c
      mysys/mf_keycache.c
      mysys/mf_keycaches.c
      mysys/mf_sort.c
      mysys/mf_tempdir.c
      mysys/mf_wfile.c
      mysys/my_alloc.c
      mysys/my_bitmap.c
      mysys/my_compress.c
      mysys/my_error.c
      mysys/my_file.c
      mysys/my_fopen.c
      mysys/my_gethwaddr.c
      mysys/my_getopt.c
      mysys/my_init.c
      mysys/my_largepage.c
      mysys/my_lib.c
      mysys/my_lockmem.c
      mysys/my_malloc.c
      mysys/my_once.c
      mysys/my_open.c
      mysys/my_realloc.c
      mysys/my_windac.c
      mysys/queues.c
      mysys/string.c
      mysys/test_charset.c
      mysys/testhash.c
      mysys/thr_alarm.c
      mysys/tree.c
      mysys/trie.c
      plugin/daemon_example/daemon_example.cc
      plugin/semisync/semisync_master.h
      scripts/mysql_config.pl.in
      scripts/mysql_config.sh
      sql-common/client.c
      sql/debug_sync.cc
      sql/derror.cc
      sql/event_data_objects.cc
      sql/event_scheduler.cc
      sql/examples/CMakeLists.txt
      sql/filesort.cc
      sql/gstream.h
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ha_partition.cc
      sql/handler.cc
      sql/handler.h
      sql/item_func.cc
      sql/keycaches.cc
      sql/lock.cc
      sql/log.cc
      sql/log_event.cc
      sql/log_event.h
      sql/log_event_old.cc
      sql/mdl.cc
      sql/mysqld.cc
      sql/net_serv.cc
      sql/opt_range.cc
      sql/records.cc
      sql/repl_failsafe.cc
      sql/rpl_filter.cc
      sql/rpl_handler.cc
      sql/rpl_injector.cc
      sql/rpl_mi.cc
      sql/rpl_rli.cc
      sql/rpl_utility.cc
      sql/slave.cc
      sql/sp_pcontext.cc
      sql/sp_rcontext.cc
      sql/sql_base.cc
      sql/sql_binlog.cc
      sql/sql_cache.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_connect.cc
      sql/sql_db.cc
      sql/sql_handler.cc
      sql/sql_insert.cc
      sql/sql_lex.cc
      sql/sql_list.h
      sql/sql_load.cc
      sql/sql_locale.cc
      sql/sql_manager.cc
      sql/sql_map.cc
      sql/sql_parse.cc
      sql/sql_partition.cc
      sql/sql_plugin.cc
      sql/sql_plugin.h
      sql/sql_profile.cc
      sql/sql_profile.h
      sql/sql_select.cc
      sql/sql_show.cc
      sql/sql_string.h
      sql/sql_table.cc
      sql/sql_test.cc
      sql/sql_truncate.cc
      sql/sys_vars.h
      sql/table.cc
      sql/uniques.cc
      sql/unireg.cc
      storage/archive/archive_reader.c
      storage/archive/ha_archive.cc
      storage/blackhole/ha_blackhole.cc
      storage/csv/ha_tina.cc
      storage/csv/ha_tina.h
      storage/csv/transparent_file.cc
      storage/example/ha_example.cc
      storage/heap/ha_heap.cc
      storage/heap/hp_block.c
      storage/heap/hp_close.c
      storage/heap/hp_create.c
      storage/heap/hp_rename.c
      storage/ibmdb2i/db2i_constraints.cc
      storage/ibmdb2i/db2i_conversion.cc
      storage/ibmdb2i/db2i_file.cc
      storage/ibmdb2i/db2i_file.h
      storage/ibmdb2i/db2i_global.h
      storage/ibmdb2i/db2i_ileBridge.cc
      storage/ibmdb2i/db2i_ileBridge.h
      storage/ibmdb2i/ha_ibmdb2i.cc
      storage/innobase/handler/ha_innodb.cc
      storage/myisam/ft_boolean_search.c
      storage/myisam/ft_nlq_search.c
      storage/myisam/ft_stopwords.c
      storage/myisam/ha_myisam.cc
      storage/myisam/mi_check.c
      storage/myisam/mi_close.c
      storage/myisam/mi_create.c
      storage/myisam/mi_dynrec.c
      storage/myisam/mi_open.c
      storage/myisam/mi_packrec.c
      storage/myisam/mi_preload.c
      storage/myisam/mi_test2.c
      storage/myisam/mi_write.c
      storage/myisam/myisamchk.c
      storage/myisam/myisamlog.c
      storage/myisam/myisampack.c
      storage/myisam/rt_index.c
      storage/myisam/sort.c
      storage/myisammrg/ha_myisammrg.cc
      storage/myisammrg/myrg_close.c
      storage/myisammrg/myrg_open.c
      storage/ndb/config/win-lib.am
      storage/ndb/config/win-prg.am
      storage/ndb/include/util/NdbAutoPtr.hpp
      storage/ndb/src/mgmapi/mgmapi.cpp
      storage/ndb/src/mgmapi/ndb_logevent.cpp
      storage/ndb/test/ndbapi/testIndexStat.cpp
      storage/ndb/tools/restore/consumer_restore.cpp
      storage/perfschema/pfs.cc
      tests/mysql_client_test.c
      tests/thread_test.c
      vio/test-ssl.c
      vio/test-sslclient.c
      vio/test-sslserver.c
      vio/vio.c
      vio/viosslfactories.c
      vio/viotest-ssl.c
=== modified file 'BUILD/SETUP.sh'
--- a/BUILD/SETUP.sh	2010-06-17 13:31:51 +0000
+++ b/BUILD/SETUP.sh	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'BUILD/build_mccge.sh'
--- a/BUILD/build_mccge.sh	2010-06-17 13:31:51 +0000
+++ b/BUILD/build_mccge.sh	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'BUILD/compile-ia64-debug-max'
--- a/BUILD/compile-ia64-debug-max	2007-01-28 20:09:54 +0000
+++ b/BUILD/compile-ia64-debug-max	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'CMakeLists.txt'
--- a/CMakeLists.txt	2010-06-18 15:04:15 +0000
+++ b/CMakeLists.txt	2010-07-01 15:12:33 +0000
@@ -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")

=== modified file 'client/completion_hash.cc'
--- a/client/completion_hash.cc	2007-05-10 09:59:39 +0000
+++ b/client/completion_hash.cc	2010-07-01 15:12:33 +0000
@@ -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);
 }
 
 

=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2010-06-11 01:30:49 +0000
+++ b/client/mysql.cc	2010-07-01 15:12:33 +0000
@@ -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 m
     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 **
   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__((un
       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, ch
 {
   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);

=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc	2010-06-11 01:30:49 +0000
+++ b/client/mysqladmin.cc	2010-07-01 15:12:33 +0000
@@ -236,7 +236,7 @@ get_one_option(int optid, const struct m
     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
       /* 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;

=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2010-06-11 01:30:49 +0000
+++ b/client/mysqlbinlog.cc	2010-07-01 15:12:33 +0000
@@ -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
 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_
   {
     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_
   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_IN
         */
         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_IN
       }
 
       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 m
       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 */

=== modified file 'client/mysqlcheck.c'
--- a/client/mysqlcheck.c	2010-06-11 01:30:49 +0000
+++ b/client/mysqlcheck.c	2010-07-01 15:12:33 +0000
@@ -291,7 +291,7 @@ get_one_option(int optid, const struct m
     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
     }
     *--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
     *--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(cha
     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);

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2010-06-11 01:30:49 +0000
+++ b/client/mysqldump.c	2010-07-01 15:12:33 +0000
@@ -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 m
     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 *
   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 *po
   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 *d
               }
             }
 
-            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 *ta
           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,
         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 *d
     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
     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

=== modified file 'client/mysqlimport.c'
--- a/client/mysqlimport.c	2010-06-11 01:30:49 +0000
+++ b/client/mysqlimport.c	2010-07-01 15:12:33 +0000
@@ -230,7 +230,7 @@ get_one_option(int optid, const struct m
     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);

=== modified file 'client/mysqlshow.c'
--- a/client/mysqlshow.c	2010-06-11 01:30:49 +0000
+++ b/client/mysqlshow.c	2010-07-01 15:12:33 +0000
@@ -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 m
     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)

=== modified file 'client/mysqlslap.c'
--- a/client/mysqlslap.c	2010-06-11 01:30:49 +0000
+++ b/client/mysqlslap.c	2010-07-01 15:12:33 +0000
@@ -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
   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 m
     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);
   }
 }
 

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-06-11 01:30:49 +0000
+++ b/client/mysqltest.cc	2010-07-01 15:12:33 +0000
@@ -84,10 +84,10 @@ static my_bool get_one_option(int optid,
 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, *bloc
 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* v
 
 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_comma
   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 m
       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 m
   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 *
   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_com
     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 *c
     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 *c
 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_re
   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_l
       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
   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
 	  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_ARR
     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 *p
   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 */
 

=== modified file 'client/readline.cc'
--- a/client/readline.cc	2009-09-11 20:26:35 +0000
+++ b/client/readline.cc	2010-07-01 15:12:33 +0000
@@ -35,7 +35,7 @@ LINE_BUFFER *batch_readline_init(ulong m
     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 *lin
 {
   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
       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;

=== modified file 'client/sql_string.h'
--- a/client/sql_string.h	2009-11-11 20:19:41 +0000
+++ b/client/sql_string.h	2010-07-01 15:12:33 +0000
@@ -175,7 +175,7 @@ public:
     {
       alloced=0;
       Alloced_length=0;
-      my_free(Ptr,MYF(0));
+      my_free(Ptr);
       Ptr=0;
       str_length=0;				/* Safety */
     }

=== modified file 'configure.in'
--- a/configure.in	2010-06-26 07:43:00 +0000
+++ b/configure.in	2010-07-01 15:12:33 +0000
@@ -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])

=== modified file 'dbug/CMakeLists.txt'
--- a/dbug/CMakeLists.txt	2009-11-24 23:15:47 +0000
+++ b/dbug/CMakeLists.txt	2010-07-01 15:12:33 +0000
@@ -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)

=== modified file 'dbug/Makefile.am'
--- a/dbug/Makefile.am	2009-10-30 18:13:58 +0000
+++ b/dbug/Makefile.am	2010-07-01 15:12:33 +0000
@@ -19,7 +19,7 @@ INCLUDES =              -I$(top_builddir
 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 \

=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c	2010-05-24 18:57:25 +0000
+++ b/dbug/dbug.c	2010-07-01 15:12:33 +0000
@@ -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
       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 *
   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_, cons
     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
 #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)

=== removed file 'dbug/sanity.c'
--- a/dbug/sanity.c	2001-09-13 23:54:33 +0000
+++ b/dbug/sanity.c	1970-01-01 00:00:00 +0000
@@ -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

=== modified file 'dbug/user.r'
--- a/dbug/user.r	2009-10-30 18:13:58 +0000
+++ b/dbug/user.r	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'extra/comp_err.c'
--- a/extra/comp_err.c	2010-06-11 01:30:49 +0000
+++ b/extra/comp_err.c	2010-07-01 15:12:33 +0000
@@ -387,15 +387,15 @@ static void clean_up(struct languages *l
   struct errors *tmp_error, *next_error;
   uint count, i;
 
-  my_free((uchar*) default_language, MYF(0));
+  my_free(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 *l
     {
       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(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(tmp_error->sql_code2);
+    my_free(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);
 }
 

=== modified file 'extra/my_print_defaults.c'
--- a/extra/my_print_defaults.c	2010-06-11 01:30:49 +0000
+++ b/extra/my_print_defaults.c	2010-07-01 15:12:33 +0000
@@ -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);

=== modified file 'extra/replace.c'
--- a/extra/replace.c	2009-11-24 13:54:59 +0000
+++ b/extra/replace.c	2010-07-01 15:12:33 +0000
@@ -262,7 +262,7 @@ static int insert_pointer_name(reg1 POIN
     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 POIN
   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 * *fro
   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 * *fro
 	  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
   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);
 }
 
 

=== modified file 'include/hash.h'
--- a/include/hash.h	2010-03-31 14:05:33 +0000
+++ b/include/hash.h	2010-07-01 15:12:33 +0000
@@ -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); /* On
 #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
 }

=== modified file 'include/lf.h'
--- a/include/lf.h	2009-11-18 02:31:40 +0000
+++ b/include/lf.h	2010-07-01 15:12:33 +0000
@@ -204,7 +204,7 @@ uint lf_alloc_pool_count(LF_ALLOCATOR *a
 #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),

=== modified file 'include/my_global.h'
--- a/include/my_global.h	2010-06-07 08:47:04 +0000
+++ b/include/my_global.h	2010-07-01 15:12:33 +0000
@@ -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*, vo
 #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.

=== modified file 'include/my_list.h'
--- a/include/my_list.h	2007-05-10 09:59:39 +0000
+++ b/include/my_list.h	2010-07-01 15:12:33 +0000
@@ -37,7 +37,7 @@ extern int list_walk(LIST *,list_walk_ac
 
 #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
 }

=== modified file 'include/my_nosys.h'
--- a/include/my_nosys.h	2007-05-10 09:59:39 +0000
+++ b/include/my_nosys.h	2010-07-01 15:12:33 +0000
@@ -39,7 +39,7 @@ extern size_t my_quick_read(File Filedes
                             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

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2010-06-08 23:44:25 +0000
+++ b/include/my_sys.h	2010-07-01 15:12:33 +0000
@@ -158,46 +158,15 @@ extern int NEAR my_errno;		/* Last error
 #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)
 #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, m
 #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,con
 		      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_
 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_STRI
 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)

=== modified file 'include/mysql/psi/mysql_file.h'
--- a/include/mysql/psi/mysql_file.h	2010-03-31 14:05:33 +0000
+++ b/include/mysql/psi/mysql_file.h	2010-07-01 15:12:33 +0000
@@ -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;
 }

=== modified file 'libmysql/Makefile.am'
--- a/libmysql/Makefile.am	2010-05-19 13:00:23 +0000
+++ b/libmysql/Makefile.am	2010-07-01 15:12:33 +0000
@@ -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 \

=== modified file 'libmysql/Makefile.shared'
--- a/libmysql/Makefile.shared	2010-05-31 12:27:10 +0000
+++ b/libmysql/Makefile.shared	2010-07-01 15:12:33 +0000
@@ -49,7 +49,7 @@ mystringsobjects =	strmov.lo strxmov.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_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 \

=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c	2010-04-11 06:52:42 +0000
+++ b/libmysql/libmysql.c	2010-07-01 15:12:33 +0000
@@ -341,7 +341,7 @@ mysql_connect(MYSQL *mysql,const char *h
     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
   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
 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(voi
   {
     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_S
     }
   }
 
-  my_free((uchar*) stmt, MYF(MY_WME));
+  my_free(stmt);
 
   DBUG_RETURN(test(rc));
 }

=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc	2010-06-10 11:43:32 +0000
+++ b/libmysqld/lib_sql.cc	2010-07-01 15:12:33 +0000
@@ -76,7 +76,7 @@ void embedded_get_error(MYSQL *mysql, MY
   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(MYSQ
   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(M
     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(MYS
     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 *stm
     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
 
 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);
 }

=== modified file 'libmysqld/libmysqld.c'
--- a/libmysqld/libmysqld.c	2010-03-31 14:05:33 +0000
+++ b/libmysqld/libmysqld.c	2010-07-01 15:12:33 +0000
@@ -119,8 +119,8 @@ mysql_real_connect(MYSQL *mysql,const ch
 			       (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;
   }
 

=== modified file 'mysql-test/include/mysqld--help.inc'
--- a/mysql-test/include/mysqld--help.inc	2010-05-17 15:28:50 +0000
+++ b/mysql-test/include/mysqld--help.inc	2010-07-01 15:12:33 +0000
@@ -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);

=== modified file 'mysql-test/lib/v1/mtr_report.pl'
--- a/mysql-test/lib/v1/mtr_report.pl	2009-12-09 15:13:00 +0000
+++ b/mysql-test/lib/v1/mtr_report.pl	2010-07-01 15:12:33 +0000
@@ -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: $_";
             }

=== modified file 'mysql-test/lib/v1/mysql-test-run.pl'
--- a/mysql-test/lib/v1/mysql-test-run.pl	2010-03-15 13:57:20 +0000
+++ b/mysql-test/lib/v1/mysql-test-run.pl	2010-07-01 15:12:33 +0000
@@ -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);

=== modified file 'mysql-test/mysql-stress-test.pl'
--- a/mysql-test/mysql-stress-test.pl	2010-03-18 06:42:07 +0000
+++ b/mysql-test/mysql-stress-test.pl	2010-07-01 15:12:33 +0000
@@ -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]);

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2010-06-23 10:17:59 +0000
+++ b/mysql-test/mysql-test-run.pl	2010-07-01 15:12:33 +0000
@@ -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);

=== modified file 'mysql-test/t/bug46080-master.opt'
--- a/mysql-test/t/bug46080-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/t/bug46080-master.opt	2010-07-01 15:12:33 +0000
@@ -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

=== removed file 'mysql-test/t/mysql-bug45236-master.opt'
--- a/mysql-test/t/mysql-bug45236-master.opt	2009-12-22 09:35:56 +0000
+++ b/mysql-test/t/mysql-bug45236-master.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---loose-skip-safemalloc

=== modified file 'mysys/CMakeLists.txt'
--- a/mysys/CMakeLists.txt	2010-06-06 11:19:29 +0000
+++ b/mysys/CMakeLists.txt	2010-07-01 15:12:33 +0000
@@ -32,7 +32,7 @@ SET(MYSYS_SOURCES  array.c charset-def.c
 				my_quick.c my_read.c my_realloc.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

=== modified file 'mysys/Makefile.am'
--- a/mysys/Makefile.am	2010-05-28 22:53:26 +0000
+++ b/mysys/Makefile.am	2010-07-01 15:12:33 +0000
@@ -30,8 +30,7 @@ libmysys_a_SOURCES =    my_init.c my_get
 			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_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 \

=== modified file 'mysys/array.c'
--- a/mysys/array.c	2009-08-28 15:06:59 +0000
+++ b/mysys/array.c	2010-07-01 15:12:33 +0000
@@ -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_ARRA
     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;
   }

=== modified file 'mysys/charset.c'
--- a/mysys/charset.c	2010-03-24 15:03:44 +0000
+++ b/mysys/charset.c	2010-07-01 15:12:33 +0000
@@ -383,11 +383,11 @@ static my_bool my_read_charset_file(cons
 #endif
   }
   
-  my_free(buf, myflags);
+  my_free(buf);
   return FALSE;
 
 error:
-  my_free(buf, myflags);
+  my_free(buf);
   return TRUE;
 }
 

=== modified file 'mysys/default_modify.c'
--- a/mysys/default_modify.c	2009-09-11 20:26:35 +0000
+++ b/mysys/default_modify.c	2010-07-01 15:12:33 +0000
@@ -223,11 +223,11 @@ int modify_defaults_file(const char *fil
   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 */

=== modified file 'mysys/hash.c'
--- a/mysys/hash.c	2010-02-02 13:58:15 +0000
+++ b/mysys/hash.c	2010-07-01 15:12:33 +0000
@@ -67,8 +67,6 @@ static my_hash_value_type calc_hash(cons
   @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));

=== modified file 'mysys/lf_alloc-pin.c'
--- a/mysys/lf_alloc-pin.c	2010-05-26 14:12:23 +0000
+++ b/mysys/lf_alloc-pin.c	2010-07-01 15:12:33 +0000
@@ -472,7 +472,7 @@ void lf_alloc_destroy(LF_ALLOCATOR *allo
     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);

=== modified file 'mysys/lf_dynarray.c'
--- a/mysys/lf_dynarray.c	2009-11-18 02:31:40 +0000
+++ b/mysys/lf_dynarray.c	2010-07-01 15:12:33 +0000
@@ -57,10 +57,10 @@ static void recursive_free(void **alloc,
     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 *a
       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 *a
     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;
 }

=== modified file 'mysys/lf_hash.c'
--- a/mysys/lf_hash.c	2009-11-18 02:31:40 +0000
+++ b/mysys/lf_hash.c	2010-07-01 15:12:33 +0000
@@ -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 *ha
   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);

=== modified file 'mysys/list.c'
--- a/mysys/list.c	2007-05-10 09:59:39 +0000
+++ b/mysys/list.c	2010-07-01 15:12:33 +0000
@@ -61,8 +61,8 @@ void list_free(LIST *root, uint free_dat
   {
     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;
   }
 }

=== modified file 'mysys/mf_cache.c'
--- a/mysys/mf_cache.c	2007-05-10 09:59:39 +0000
+++ b/mysys/mf_cache.c	2010-07-01 15:12:33 +0000
@@ -71,8 +71,8 @@ my_bool open_cached_file(IO_CACHE *cache
   {
     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;
 }

=== modified file 'mysys/mf_iocache.c'
--- a/mysys/mf_iocache.c	2009-12-10 03:19:51 +0000
+++ b/mysys/mf_iocache.c	2010-07-01 15:12:33 +0000
@@ -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");

=== modified file 'mysys/mf_keycache.c'
--- a/mysys/mf_keycache.c	2009-12-10 03:19:51 +0000
+++ b/mysys/mf_keycache.c	2010-07-01 15:12:33 +0000
@@ -446,7 +446,7 @@ int init_key_cache(KEY_CACHE *keycache,
         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,
   {
     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);

=== modified file 'mysys/mf_keycaches.c'
--- a/mysys/mf_keycaches.c	2009-10-14 16:37:38 +0000
+++ b/mysys/mf_keycaches.c	2010-07-01 15:12:33 +0000
@@ -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 *
     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;
     }

=== modified file 'mysys/mf_sort.c'
--- a/mysys/mf_sort.c	2007-10-18 10:32:43 +0000
+++ b/mysys/mf_sort.c	2010-07-01 15:12:33 +0000
@@ -27,7 +27,7 @@ void my_string_ptr_sort(uchar *base, uin
       (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

=== modified file 'mysys/mf_tempdir.c'
--- a/mysys/mf_tempdir.c	2009-12-10 03:19:51 +0000
+++ b/mysys/mf_tempdir.c	2010-07-01 15:12:33 +0000
@@ -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);
 }

=== modified file 'mysys/mf_wfile.c'
--- a/mysys/mf_wfile.c	2010-06-10 20:16:43 +0000
+++ b/mysys/mf_wfile.c	2010-07-01 15:12:33 +0000
@@ -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 */

=== modified file 'mysys/my_alloc.c'
--- a/mysys/my_alloc.c	2010-06-11 13:48:24 +0000
+++ b/mysys/my_alloc.c	2010-07-01 15:12:33 +0000
@@ -120,7 +120,7 @@ void reset_root_defaults(MEM_ROOT *mem_r
         {
           /* 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 MyFla
   {
     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)

=== modified file 'mysys/my_bitmap.c'
--- a/mysys/my_bitmap.c	2009-12-10 03:19:51 +0000
+++ b/mysys/my_bitmap.c	2010-07-01 15:12:33 +0000
@@ -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;

=== modified file 'mysys/my_compress.c'
--- a/mysys/my_compress.c	2009-02-13 16:41:47 +0000
+++ b/mysys/my_compress.c	2010-07-01 15:12:33 +0000
@@ -51,7 +51,7 @@ my_bool my_compress(uchar *packet, size_
     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 *pa
 
   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, siz
     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_
 
    if (my_uncompress(data, complen, &orglen))
    {
-     my_free(data, MYF(0));
+     my_free(data);
      DBUG_RETURN(3);
    }
 

=== modified file 'mysys/my_error.c'
--- a/mysys/my_error.c	2009-11-02 20:05:42 +0000
+++ b/mysys/my_error.c	2010-07-01 15:12:33 +0000
@@ -211,7 +211,7 @@ int my_error_register(const char** (*get
   /* 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 fir
 
   /* 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. */
 

=== modified file 'mysys/my_file.c'
--- a/mysys/my_file.c	2010-04-11 07:17:42 +0000
+++ b/mysys/my_file.c	2010-07-01 15:12:33 +0000
@@ -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;
   }

=== modified file 'mysys/my_fopen.c'
--- a/mysys/my_fopen.c	2009-12-10 03:19:51 +0000
+++ b/mysys/my_fopen.c	2010-07-01 15:12:33 +0000
@@ -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);

=== modified file 'mysys/my_gethwaddr.c'
--- a/mysys/my_gethwaddr.c	2010-05-31 15:29:54 +0000
+++ b/mysys/my_gethwaddr.c	2010-07-01 15:12:33 +0000
@@ -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;
 }

=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2010-06-11 01:30:49 +0000
+++ b/mysys/my_getopt.c	2010-07-01 15:12:33 +0000
@@ -596,8 +596,7 @@ static int setval(const struct my_option
     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
     */
     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
   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 */

=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2010-06-18 15:04:15 +0000
+++ b/mysys/my_init.c	2010-07-01 15:12:33 +0000
@@ -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, Involunt
 #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, Involunt
    _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, Involunt
   if (have_tcpip)
     WSACleanup();
 #endif /* __WIN__ */
+
   my_init_done=0;
   my_basic_init_done= 0;
 } /* my_end */

=== modified file 'mysys/my_largepage.c'
--- a/mysys/my_largepage.c	2009-12-10 03:19:51 +0000
+++ b/mysys/my_largepage.c	2010-07-01 15:12:33 +0000
@@ -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
   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_fl
     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,
 
 /* 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);

=== modified file 'mysys/my_lib.c'
--- a/mysys/my_lib.c	2009-12-10 03:19:51 +0000
+++ b/mysys/my_lib.c	2010-07-01 15:12:33 +0000
@@ -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 MyF
   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 MyF
   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_ST
   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))

=== modified file 'mysys/my_lockmem.c'
--- a/mysys/my_lockmem.c	2009-12-10 03:19:51 +0000
+++ b/mysys/my_lockmem.c	2010-07-01 15:12:33 +0000
@@ -66,7 +66,7 @@ uchar *my_malloc_lock(uint size,myf MyFl
     element->list.data=(uchar*) element;
     element->page=ptr;
     element->size=size;
-    mysql_mutex_lock(&THR_LOCK_malloc);
+    mysql_mutex_lock(&THR_LOCK_alloc);
     mem_list=list_add(mem_list,&element->list);
     mysql_mutex_unlock(&THR_LOCK_malloc);
   }
@@ -74,7 +74,7 @@ uchar *my_malloc_lock(uint size,myf MyFl
 }
 
 
-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
     }
   }
   mysql_mutex_unlock(&THR_LOCK_malloc);
-  if (element)
-    my_free((uchar*) element,MYF(0));
+  my_free(element);
   free(ptr);					/* Free even if not locked */
 }
 

=== modified file 'mysys/my_malloc.c'
--- a/mysys/my_malloc.c	2010-05-21 11:23:48 +0000
+++ b/mysys/my_malloc.c	2010-07-01 15:12:33 +0000
@@ -13,10 +13,6 @@
    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"
 #include <m_string.h>
@@ -32,7 +28,7 @@ void *my_malloc(size_t size, myf my_flag
   if (!size)
     size=1;					/* Safety */
 
-  point= (char *) malloc(size);
+  point= malloc(size);
   DBUG_EXECUTE_IF("simulate_out_of_memory",
                   {
                     free(point);
@@ -61,7 +57,7 @@ void *my_malloc(size_t size, myf my_flag
 	/* Free memory allocated with my_malloc */
 	/*ARGSUSED*/
 
-void my_no_flags_free(void* ptr)
+void my_free(void* ptr)
 {
   DBUG_ENTER("my_free");
   DBUG_PRINT("my",("ptr: 0x%lx", (long) ptr));

=== modified file 'mysys/my_once.c'
--- a/mysys/my_once.c	2009-12-26 20:55:32 +0000
+++ b/mysys/my_once.c	2010-07-01 15:12:33 +0000
@@ -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"

=== modified file 'mysys/my_open.c'
--- a/mysys/my_open.c	2009-12-10 03:19:51 +0000
+++ b/mysys/my_open.c	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'mysys/my_realloc.c'
--- a/mysys/my_realloc.c	2007-10-11 15:07:40 +0000
+++ b/mysys/my_realloc.c	2010-07-01 15:12:33 +0000
@@ -13,10 +13,6 @@
    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"
 
@@ -46,7 +42,7 @@ void* my_realloc(void* oldpoint, size_t
   if (!(point = malloc(size)))
   {
     if (my_flags & MY_FREE_ON_ERROR)
-      my_free(oldpoint,my_flags);
+      my_free(oldpoint);
     if (my_flags & MY_HOLD_ON_ERROR)
       DBUG_RETURN(oldpoint);
     my_errno=errno;
@@ -62,7 +58,7 @@ void* my_realloc(void* oldpoint, size_t
   if ((point= (uchar*) realloc(oldpoint,size)) == NULL)
   {
     if (my_flags & MY_FREE_ON_ERROR)
-      my_free(oldpoint, my_flags);
+      my_free(oldpoint);
     if (my_flags & MY_HOLD_ON_ERROR)
       DBUG_RETURN(oldpoint);
     my_errno=errno;

=== modified file 'mysys/my_windac.c'
--- a/mysys/my_windac.c	2007-05-10 09:59:39 +0000
+++ b/mysys/my_windac.c	2010-07-01 15:12:33 +0000
@@ -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_ATTR
     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);
   }
 }
 

=== modified file 'mysys/queues.c'
--- a/mysys/queues.c	2008-02-18 22:29:39 +0000
+++ b/mysys/queues.c	2010-07-01 15:12:33 +0000
@@ -194,11 +194,8 @@ int resize_queue(QUEUE *queue, uint max_
 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;
 }
 

=== removed file 'mysys/safemalloc.c'
--- a/mysys/safemalloc.c	2010-06-11 13:54:39 +0000
+++ b/mysys/safemalloc.c	1970-01-01 00:00:00 +0000
@@ -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);
-}

=== modified file 'mysys/string.c'
--- a/mysys/string.c	2009-02-13 16:41:47 +0000
+++ b/mysys/string.c	2010-07-01 15:12:33 +0000
@@ -177,9 +177,6 @@ my_bool dynstr_append_os_quoted(DYNAMIC_
 
 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;
 }

=== modified file 'mysys/test_charset.c'
--- a/mysys/test_charset.c	2007-08-15 13:43:08 +0000
+++ b/mysys/test_charset.c	2010-07-01 15:12:33 +0000
@@ -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;

=== modified file 'mysys/testhash.c'
--- a/mysys/testhash.c	2007-05-10 09:59:39 +0000
+++ b/mysys/testhash.c	2010-07-01 15:12:33 +0000
@@ -286,5 +286,5 @@ static int rnd(int max_value)
 
 void free_record(void *record)
 {
-  my_free(record,MYF(0));
+  my_free(record);
 }

=== modified file 'mysys/thr_alarm.c'
--- a/mysys/thr_alarm.c	2009-12-10 03:19:51 +0000
+++ b/mysys/thr_alarm.c	2010-07-01 15:12:33 +0000
@@ -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;

=== modified file 'mysys/tree.c'
--- a/mysys/tree.c	2007-05-10 09:59:39 +0000
+++ b/mysys/tree.c	2010-07-01 15:12:33 +0000
@@ -183,7 +183,7 @@ static void delete_tree_element(TREE *tr
       (*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, u
   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;
 }

=== modified file 'mysys/trie.c'
--- a/mysys/trie.c	2007-05-10 09:59:39 +0000
+++ b/mysys/trie.c	2010-07-01 15:12:33 +0000
@@ -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);
 }
 

=== modified file 'plugin/daemon_example/daemon_example.cc'
--- a/plugin/daemon_example/daemon_example.cc	2010-05-27 11:52:01 +0000
+++ b/plugin/daemon_example/daemon_example.cc	2010-07-01 15:12:33 +0000
@@ -175,7 +175,7 @@ static int daemon_example_plugin_deinit(
   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);
 }

=== modified file 'plugin/semisync/semisync_master.h'
--- a/plugin/semisync/semisync_master.h	2010-06-05 19:39:03 +0000
+++ b/plugin/semisync/semisync_master.h	2010-07-01 15:12:33 +0000
@@ -255,7 +255,7 @@ private:
    */
   void free_block(Block *block)
   {
-    my_free(block, MYF(0));
+    my_free(block);
     --block_num;
   }
 

=== modified file 'scripts/mysql_config.pl.in'
--- a/scripts/mysql_config.pl.in	2009-09-08 13:35:01 +0000
+++ b/scripts/mysql_config.pl.in	2010-07-01 15:12:33 +0000
@@ -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/;

=== modified file 'scripts/mysql_config.sh'
--- a/scripts/mysql_config.sh	2009-09-22 23:26:08 +0000
+++ b/scripts/mysql_config.sh	2010-07-01 15:12:33 +0000
@@ -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 \

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2010-05-11 08:27:53 +0000
+++ b/sql-common/client.c	2010-07-01 15:12:33 +0000
@@ -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_my
   {
     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 s
 	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 s
 	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 s
 	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 s
 	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 s
 	  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 s
 	  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 s
         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_
   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,cons
 			       (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
   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(MYS
 {
   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(MYS
 
 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(M
   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
   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_op
     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_op
   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;

=== modified file 'sql/debug_sync.cc'
--- a/sql/debug_sync.cc	2010-06-05 19:39:03 +0000
+++ b/sql/debug_sync.cc	2010-07-01 15:12:33 +0000
@@ -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;
   }
 

=== modified file 'sql/derror.cc'
--- a/sql/derror.cc	2010-05-31 15:29:54 +0000
+++ b/sql/derror.cc	2010-07-01 15:12:33 +0000
@@ -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 v
     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))))
   {

=== modified file 'sql/event_data_objects.cc'
--- a/sql/event_data_objects.cc	2010-06-11 13:54:39 +0000
+++ b/sql/event_data_objects.cc	2010-07-01 15:12:33 +0000
@@ -176,7 +176,7 @@ Event_queue_element_for_exec::init(LEX_S
     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_S
 
 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);
 }
 
 

=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc	2010-06-10 11:43:32 +0000
+++ b/sql/event_scheduler.cc	2010-07-01 15:12:33 +0000
@@ -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);
 

=== modified file 'sql/examples/CMakeLists.txt'
--- a/sql/examples/CMakeLists.txt	2006-12-31 00:02:27 +0000
+++ b/sql/examples/CMakeLists.txt	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2010-04-29 20:33:06 +0000
+++ b/sql/filesort.cc	2010-07-01 15:12:33 +0000
@@ -264,7 +264,7 @@ ha_rows filesort(THD *thd, TABLE *table,
   {
     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,
   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,
 
 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_
     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;
     }
   }

=== modified file 'sql/gstream.h'
--- a/sql/gstream.h	2010-03-31 14:05:33 +0000
+++ b/sql/gstream.h	2010-07-01 15:12:33 +0000
@@ -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();

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-06-10 11:43:32 +0000
+++ b/sql/ha_ndbcluster.cc	2010-07-01 15:12:33 +0000
@@ -1035,7 +1035,7 @@ int get_ndb_blobs_value(TABLE* table, Nd
     }
     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 ch
   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 ch
     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(N
   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_DA
 {
   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 *na
     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(
       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(
       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
 
   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 ch
       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_SHAR
   }
 #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->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 *t
   }
   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);
 }
 

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2010-06-17 13:31:51 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2010-07-01 15:12:33 +0000
@@ -1020,7 +1020,7 @@ static void ndbcluster_get_schema(NDB_SH
                                  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_SH
   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 *
           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 *
 
       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
 
   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
     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_S
     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

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2010-06-17 13:31:51 +0000
+++ b/sql/ha_partition.cc	2010-07-01 15:12:33 +0000
@@ -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(c
   }
   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
 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);

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2010-06-08 17:47:10 +0000
+++ b/sql/handler.cc	2010-07-01 15:12:33 +0000
@@ -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
     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
   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_
 
 void fl_log_iterator_destroy(struct handler_iterator *iterator)
 {
-  my_free((uchar*)iterator->buffer, MYF(MY_ALLOW_ZERO_PTR));
+  my_free(iterator->buffer);
 }
 
 

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2010-06-11 01:30:49 +0000
+++ b/sql/handler.h	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2010-06-25 15:32:59 +0000
+++ b/sql/item_func.cc	2010-07-01 15:12:33 +0000
@@ -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
     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
   {
     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
       if (entry->value != pos)
       {
 	if (entry->value)
-	  my_free(entry->value,MYF(0));
+	  my_free(entry->value);
 	entry->value=pos;
       }
     }

=== modified file 'sql/keycaches.cc'
--- a/sql/keycaches.cc	2009-12-22 09:35:56 +0000
+++ b/sql/keycaches.cc	2010-07-01 15:12:33 +0000
@@ -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 *
   {
     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
 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);
 }
 
 

=== modified file 'sql/lock.cc'
--- a/sql/lock.cc	2010-06-11 15:28:18 +0000
+++ b/sql/lock.cc	2010-07-01 15:12:33 +0000
@@ -262,7 +262,7 @@ static void reset_lock_data(MYSQL_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
     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 *t
   {
     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 *th
                                      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
   }
 
   /* 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);

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-06-30 19:32:05 +0000
+++ b/sql/log.cc	2010-07-01 15:12:33 +0000
@@ -1501,7 +1501,7 @@ static int binlog_close_connection(handl
   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
   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
     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
   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 n
   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:

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-06-30 15:25:13 +0000
+++ b/sql/log_event.cc	2010-07-01 15:12:33 +0000
@@ -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* f
     }
   }
     
-  my_free(tmp_str, MYF(0));
+  my_free(tmp_str);
   DBUG_VOID_RETURN;
 }
 
@@ -2146,7 +2146,7 @@ void Query_log_event::pack_info(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*
       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
     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(Proto
   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* th
 
 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_eve
     {
       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_
   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_e
   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_e
   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
 
 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(
       (!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_oper
 {
   /*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_oper
 {
   /*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;

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2010-05-28 05:47:58 +0000
+++ b/sql/log_event.h	2010-07-01 15:12:33 +0000
@@ -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()

=== modified file 'sql/log_event_old.cc'
--- a/sql/log_event_old.cc	2010-06-03 23:47:30 +0000
+++ b/sql/log_event_old.cc	2010-07-01 15:12:33 +0000
@@ -1017,7 +1017,7 @@ int Delete_rows_log_event_old::do_after_
 {
   /*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_
 {
   /*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_
 {
   /*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_
 {
   /*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;

=== modified file 'sql/mdl.cc'
--- a/sql/mdl.cc	2010-06-07 07:06:55 +0000
+++ b/sql/mdl.cc	2010-07-01 15:12:33 +0000
@@ -1935,7 +1935,7 @@ bool MDL_context::acquire_locks(MDL_requ
     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;
 }
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-06-17 20:51:35 +0000
+++ b/sql/mysqld.cc	2010-07-01 15:12:33 +0000
@@ -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",
     }
     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;
     }
   }

=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc	2010-06-09 08:41:24 +0000
+++ b/sql/net_serv.cc	2010-07-01 15:12:33 +0000
@@ -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 *pac
 #endif
 #ifdef HAVE_COMPRESS
   if (net->compress)
-    my_free((char*) packet,MYF(0));
+    my_free((void*) packet);
 #endif
   if (thr_alarm_in_use(&alarmed))
   {

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2010-06-22 20:32:29 +0000
+++ b/sql/opt_range.cc	2010-07-01 15:12:33 +0000
@@ -1091,7 +1091,7 @@ SQL_SELECT *make_select(TABLE *head, tab
     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);

=== modified file 'sql/records.cc'
--- a/sql/records.cc	2010-06-22 20:32:29 +0000
+++ b/sql/records.cc	2010-07-01 15:12:33 +0000
@@ -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)

=== modified file 'sql/repl_failsafe.cc'
--- a/sql/repl_failsafe.cc	2010-06-11 15:28:18 +0000
+++ b/sql/repl_failsafe.cc	2010-07-01 15:12:33 +0000
@@ -205,7 +205,7 @@ int register_slave(THD* thd, uchar* pack
   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

=== modified file 'sql/rpl_filter.cc'
--- a/sql/rpl_filter.cc	2010-03-31 14:05:33 +0000
+++ b/sql/rpl_filter.cc	2010-07-01 15:12:33 +0000
@@ -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_AR
   {
     char* p;
     get_dynamic(a, (uchar*) &p, i);
-    my_free(p, MYF(MY_WME));
+    my_free(p);
   }
   delete_dynamic(a);
 }

=== modified file 'sql/rpl_handler.cc'
--- a/sql/rpl_handler.cc	2010-05-26 14:12:23 +0000
+++ b/sql/rpl_handler.cc	2010-07-01 15:12:33 +0000
@@ -213,7 +213,7 @@ int Trans_delegate::after_commit(THD *th
   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 *
   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;
 }

=== modified file 'sql/rpl_injector.cc'
--- a/sql/rpl_injector.cc	2010-03-31 14:05:33 +0000
+++ b/sql/rpl_injector.cc	2010-07-01 15:12:33 +0000
@@ -58,7 +58,7 @@ injector::transaction::~transaction()
   */
   *the_memory= '\0';
 
-  my_free(the_memory, MYF(0));
+  my_free(the_memory);
 }
 
 /**

=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc	2010-06-02 08:11:49 +0000
+++ b/sql/rpl_mi.cc	2010-07-01 15:12:33 +0000
@@ -498,7 +498,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)

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2010-03-31 14:05:33 +0000
+++ b/sql/rpl_rli.cc	2010-07-01 15:12:33 +0000
@@ -1251,7 +1251,7 @@ void Relay_log_info::clear_tables_to_loc
     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);
 }

=== modified file 'sql/rpl_utility.cc'
--- a/sql/rpl_utility.cc	2010-03-31 14:05:33 +0000
+++ b/sql/rpl_utility.cc	2010-07-01 15:12:33 +0000
@@ -1047,7 +1047,7 @@ table_def::table_def(unsigned char *type
 
 table_def::~table_def()
 {
-  my_free(m_memory, MYF(0));
+  my_free(m_memory);
 #ifndef DBUG_OFF
   m_type= 0;
   m_size= 0;

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2010-06-10 11:43:32 +0000
+++ b/sql/slave.cc	2010-07-01 15:12:33 +0000
@@ -1154,7 +1154,7 @@ int init_dynarray_intvar_from_file(DYNAM
   }
 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(Mast
     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(Mast
     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(Mast
     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);

=== modified file 'sql/sp_pcontext.cc'
--- a/sql/sp_pcontext.cc	2010-03-31 14:05:33 +0000
+++ b/sql/sp_pcontext.cc	2010-07-01 15:12:33 +0000
@@ -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"
 

=== modified file 'sql/sp_rcontext.cc'
--- a/sql/sp_rcontext.cc	2010-03-31 14:05:33 +0000
+++ b/sql/sp_rcontext.cc	2010-07-01 15:12:33 +0000
@@ -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"

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2010-06-17 13:31:51 +0000
+++ b/sql/sql_base.cc	2010-07-01 15:12:33 +0000
@@ -885,7 +885,7 @@ static void free_cache_entry(TABLE *tabl
 
   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;
@@ -2135,7 +2135,7 @@ void close_temporary(TABLE *table, bool
   if (free_share)
   {
     free_table_share(table->s);
-    my_free((char*) table,MYF(0));
+    my_free(table);
   }
   DBUG_VOID_RETURN;
 }
@@ -3017,7 +3017,7 @@ bool open_table(THD *thd, TABLE_LIST *ta
 
     if (error)
     {
-      my_free(table, MYF(0));
+      my_free(table);
 
       if (error == 7)
         (void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER,
@@ -3032,7 +3032,7 @@ bool open_table(THD *thd, TABLE_LIST *ta
     if (open_table_entry_fini(thd, share, table))
     {
       closefrm(table, 0);
-      my_free((uchar*)table, MYF(0));
+      my_free(table);
       goto err_lock;
     }
 
@@ -3778,10 +3778,10 @@ static bool open_table_entry_fini(THD *t
                               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
       {
@@ -3866,7 +3866,7 @@ static bool auto_repair_table(THD *thd,
     closefrm(entry, 0);
     result= FALSE;
   }
-  my_free(entry, MYF(0));
+  my_free(entry);
 
   mysql_mutex_lock(&LOCK_open);
   release_table_share(share);
@@ -5750,7 +5750,7 @@ TABLE *open_temporary_table(THD *thd, co
   {
     /* 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);
   }
 

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2010-03-31 14:05:33 +0000
+++ b/sql/sql_binlog.cc	2010-07-01 15:12:33 +0000
@@ -252,6 +252,6 @@ void mysql_client_binlog_statement(THD*
 
 end:
   rli->slave_close_thread_tables(thd);
-  my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
+  my_free(buf);
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2010-05-05 22:02:08 +0000
+++ b/sql/sql_cache.cc	2010-07-01 15:12:33 +0000
@@ -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);

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-06-30 15:25:13 +0000
+++ b/sql/sql_class.cc	2010-07-01 15:12:33 +0000
@@ -100,8 +100,8 @@ extern "C" void free_user_var(user_var_e
 {
   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
 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);
     }
 
     /**

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-06-30 15:25:13 +0000
+++ b/sql/sql_class.h	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2010-06-17 13:31:51 +0000
+++ b/sql/sql_connect.cc	2010-07-01 15:12:33 +0000
@@ -98,7 +98,7 @@ static int get_or_create_user_conn(THD *
     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
 
 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);

=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc	2010-05-25 12:35:01 +0000
+++ b/sql/sql_db.cc	2010-07-01 15:12:33 +0000
@@ -94,7 +94,7 @@ extern "C" void lock_db_free_element(voi
 
 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
     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 *dbn
     
     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 *th
       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
   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
              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
                           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
       /* 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. */
 

=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc	2010-06-17 13:31:51 +0000
+++ b/sql/sql_handler.cc	2010-07-01 15:12:33 +0000
@@ -109,7 +109,7 @@ static char *mysql_ha_hash_get_key(TABLE
 
 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
     /* 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);
     }

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2010-06-10 11:43:32 +0000
+++ b/sql/sql_insert.cc	2010-07-01 15:12:33 +0000
@@ -93,7 +93,7 @@ static bool check_view_insertability(THD
 #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
   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(re
     {
       uchar *str;
       ((Field_blob *) (*ptr))->get_ptr(&str);
-      my_free(str,MYF(MY_ALLOW_ZERO_PTR));
+      my_free(str);
       ((Field_blob *) (*ptr))->reset();
     }
   }

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2010-06-17 13:31:51 +0000
+++ b/sql/sql_lex.cc	2010-07-01 15:12:33 +0000
@@ -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);
   }
 }
 

=== modified file 'sql/sql_list.h'
--- a/sql/sql_list.h	2010-06-11 01:30:49 +0000
+++ b/sql/sql_list.h	2010-07-01 15:12:33 +0000
@@ -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()

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2010-06-09 08:41:24 +0000
+++ b/sql/sql_load.cc	2010-07-01 15:12:33 +0000
@@ -1337,7 +1337,7 @@ READ_INFO::READ_INFO(File file_par, uint
 		      (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);

=== modified file 'sql/sql_locale.cc'
--- a/sql/sql_locale.cc	2010-03-31 14:05:33 +0000
+++ b/sql/sql_locale.cc	2010-07-01 15:12:33 +0000
@@ -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);
   }
 }

=== modified file 'sql/sql_manager.cc'
--- a/sql/sql_manager.cc	2010-06-10 11:43:32 +0000
+++ b/sql/sql_manager.cc	2010-07-01 15:12:33 +0000
@@ -117,7 +117,7 @@ pthread_handler_t handle_manager(void *a
     {
       struct handler_cb *next= cb->next;
       cb->action();
-      my_free((uchar*)cb, MYF(0));
+      my_free(cb);
       cb= next;
     }
   }

=== modified file 'sql/sql_map.cc'
--- a/sql/sql_map.cc	2010-03-31 14:05:33 +0000
+++ b/sql/sql_map.cc	2010-07-01 15:12:33 +0000
@@ -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
 }
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2010-06-30 15:25:13 +0000
+++ b/sql/sql_parse.cc	2010-07-01 15:12:33 +0000
@@ -1058,7 +1058,7 @@ bool dispatch_command(enum enum_server_c
 
     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_c
       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_c
 #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();

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2010-06-11 13:48:24 +0000
+++ b/sql/sql_partition.cc	2010-07-01 15:12:33 +0000
@@ -2624,7 +2624,7 @@ char *generate_partition_syntax(partitio
   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;
   }

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2010-06-17 13:31:51 +0000
+++ b/sql/sql_plugin.cc	2010-07-01 15:12:33 +0000
@@ -254,10 +254,9 @@ static void plugin_vars_free_values(sys_
 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(struc
   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 cha
 }
 
 
-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
       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
 }
 
 
-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_
 }
 
 
-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 *le
   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, st
   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,
         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,
 
   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_
       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;
     }
   }

=== modified file 'sql/sql_plugin.h'
--- a/sql/sql_plugin.h	2010-03-31 14:05:33 +0000
+++ b/sql/sql_plugin.h	2010-07-01 15:12:33 +0000
@@ -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 *
 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,

=== modified file 'sql/sql_profile.cc'
--- a/sql/sql_profile.cc	2010-03-31 14:05:33 +0000
+++ b/sql/sql_profile.cc	2010-07-01 15:12:33 +0000
@@ -177,8 +177,7 @@ PROF_MEASUREMENT::PROF_MEASUREMENT(QUERY
 
 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);
 }
 
 /**

=== modified file 'sql/sql_profile.h'
--- a/sql/sql_profile.h	2010-04-12 13:17:37 +0000
+++ b/sql/sql_profile.h	2010-07-01 15:12:33 +0000
@@ -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;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-06-25 22:06:53 +0000
+++ b/sql/sql_select.cc	2010-07-01 15:12:33 +0000
@@ -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(TH
   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(TH
     }
     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 *table
 
 		  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 */
   }

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2010-06-17 13:31:51 +0000
+++ b/sql/sql_show.cc	2010-07-01 15:12:33 +0000
@@ -1353,7 +1353,7 @@ int store_create_info(THD *thd, TABLE_LI
       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_LI
        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(TH
     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_reco
       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_in
       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
       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);
 }

=== modified file 'sql/sql_string.h'
--- a/sql/sql_string.h	2010-04-13 21:56:19 +0000
+++ b/sql/sql_string.h	2010-07-01 15:12:33 +0000
@@ -205,7 +205,7 @@ public:
     {
       alloced=0;
       Alloced_length=0;
-      my_free(Ptr,MYF(0));
+      my_free(Ptr);
       Ptr=0;
       str_length=0;				/* Safety */
     }

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-06-25 15:32:59 +0000
+++ b/sql/sql_table.cc	2010-07-01 15:12:33 +0000
@@ -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_PAR
     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;
@@ -7531,7 +7531,7 @@ bool mysql_alter_table(THD *thd,char *ne
     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",

=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc	2010-06-06 11:19:29 +0000
+++ b/sql/sql_test.cc	2010-07-01 15:12:33 +0000
@@ -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\

=== modified file 'sql/sql_truncate.cc'
--- a/sql/sql_truncate.cc	2010-05-27 21:11:55 +0000
+++ b/sql/sql_truncate.cc	2010-07-01 15:12:33 +0000
@@ -216,7 +216,7 @@ static bool recreate_temporary_table(THD
     rm_temporary_table(table_type, share->path.str);
 
   free_table_share(share);
-  my_free(table, MYF(0));
+  my_free(table);
 
   DBUG_RETURN(error);
 }

=== modified file 'sql/sys_vars.h'
--- a/sql/sys_vars.h	2010-05-07 16:28:59 +0000
+++ b/sql/sys_vars.h	2010-07-01 15:12:33 +0000
@@ -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;

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2010-06-22 20:32:29 +0000
+++ b/sql/table.cc	2010-07-01 15:12:33 +0000
@@ -896,7 +896,7 @@ static int open_binary_frm(THD *thd, TAB
     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, TAB
                                                   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, TAB
                 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, TAB
           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, TAB
         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, TAB
               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, TAB
       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, TAB
         {
           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, TAB
         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, TAB
       {
           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, TAB
   }
   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, TAB
   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
 
   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, uch
 
   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, si
 {
   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 */
   }

=== modified file 'sql/uniques.cc'
--- a/sql/uniques.cc	2010-03-31 14:05:33 +0000
+++ b/sql/uniques.cc	2010-07-01 15:12:33 +0000
@@ -566,7 +566,7 @@ bool Unique::walk(tree_walk_action actio
                   (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;
 

=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc	2010-06-11 01:30:49 +0000
+++ b/sql/unireg.cc	2010-07-01 15:12:33 +0000
@@ -148,7 +148,7 @@ bool mysql_create_frm(THD *thd, const ch
 
   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 ch
                     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 ch
     {
       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 ch
   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 ch
     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 ch
   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, Fil
   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 */

=== modified file 'storage/archive/archive_reader.c'
--- a/storage/archive/archive_reader.c	2010-06-11 01:30:49 +0000
+++ b/storage/archive/archive_reader.c	2010-07-01 15:12:33 +0000
@@ -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:

=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc	2010-04-19 12:09:44 +0000
+++ b/storage/archive/ha_archive.cc	2010-07-01 15:12:33 +0000
@@ -387,7 +387,7 @@ ARCHIVE_SHARE *ha_archive::get_share(con
     {
       *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,
         {
           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::creat
   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::creat
 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;
 }
 

=== modified file 'storage/blackhole/ha_blackhole.cc'
--- a/storage/blackhole/ha_blackhole.cc	2010-03-31 14:05:33 +0000
+++ b/storage/blackhole/ha_blackhole.cc	2010-07-01 15:12:33 +0000
@@ -335,7 +335,7 @@ static st_blackhole_share *get_share(con
     
     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_shar
 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,

=== modified file 'storage/csv/ha_tina.cc'
--- a/storage/csv/ha_tina.cc	2010-04-01 12:19:08 +0000
+++ b/storage/csv/ha_tina.cc	2010-07-01 15:12:33 +0000
@@ -251,7 +251,7 @@ static TINA_SHARE *get_share(const char
 
 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_O
 
   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_OP
 
   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)

=== modified file 'storage/csv/ha_tina.h'
--- a/storage/csv/ha_tina.h	2009-12-05 01:26:15 +0000
+++ b/storage/csv/ha_tina.h	2010-07-01 15:12:33 +0000
@@ -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));

=== modified file 'storage/csv/transparent_file.cc'
--- a/storage/csv/transparent_file.cc	2010-03-31 14:05:33 +0000
+++ b/storage/csv/transparent_file.cc	2010-07-01 15:12:33 +0000
@@ -29,7 +29,7 @@ Transparent_file::Transparent_file() : l
 
 Transparent_file::~Transparent_file()
 { 
-  my_free((uchar*)buff, MYF(MY_ALLOW_ZERO_PTR)); 
+  my_free(buff);
 }
 
 void Transparent_file::init_buff(File filedes_arg)

=== modified file 'storage/example/ha_example.cc'
--- a/storage/example/ha_example.cc	2010-03-31 14:05:33 +0000
+++ b/storage/example/ha_example.cc	2010-07-01 15:12:33 +0000
@@ -232,7 +232,7 @@ static EXAMPLE_SHARE *get_share(const ch
 
 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 *sha
     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);
 

=== modified file 'storage/heap/ha_heap.cc'
--- a/storage/heap/ha_heap.cc	2010-06-11 15:28:18 +0000
+++ b/storage/heap/ha_heap.cc	2010-07-01 15:12:33 +0000
@@ -112,7 +112,7 @@ int ha_heap::open(const char *name, int
     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, TA
   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);
 }

=== modified file 'storage/heap/hp_block.c'
--- a/storage/heap/hp_block.c	2007-05-10 09:59:39 +0000
+++ b/storage/heap/hp_block.c	2010-07-01 15:12:33 +0000
@@ -145,7 +145,7 @@ uchar *hp_free_level(HP_BLOCK *block, ui
   }
   if ((uchar*) pos != last_pos)
   {
-    my_free((uchar*) pos,MYF(0));
+    my_free(pos);
     return last_pos;
   }
   return next_ptr;			/* next memory position */

=== modified file 'storage/heap/hp_close.c'
--- a/storage/heap/hp_close.c	2009-12-05 01:26:15 +0000
+++ b/storage/heap/hp_close.c	2010-07-01 15:12:33 +0000
@@ -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);
 }

=== modified file 'storage/heap/hp_create.c'
--- a/storage/heap/hp_create.c	2010-06-11 15:28:18 +0000
+++ b/storage/heap/hp_create.c	2010-07-01 15:12:33 +0000
@@ -189,7 +189,7 @@ int heap_create(const char *name, HP_CRE
     /* 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;
 }

=== modified file 'storage/heap/hp_rename.c'
--- a/storage/heap/hp_rename.c	2009-12-05 01:26:15 +0000
+++ b/storage/heap/hp_rename.c	2010-07-01 15:12:33 +0000
@@ -33,7 +33,7 @@ int heap_rename(const char *old_name, co
       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);

=== modified file 'storage/ibmdb2i/db2i_constraints.cc'
--- a/storage/ibmdb2i/db2i_constraints.cc	2009-12-22 06:36:04 +0000
+++ b/storage/ibmdb2i/db2i_constraints.cc	2010-07-01 15:12:33 +0000
@@ -421,7 +421,7 @@ void ha_ibmdb2i::free_foreign_key_create
 
   if (info)
   {
-    my_free(info, MYF(0));
+    my_free(info);
   }
   DBUG_VOID_RETURN;
 }

=== modified file 'storage/ibmdb2i/db2i_conversion.cc'
--- a/storage/ibmdb2i/db2i_conversion.cc	2009-07-06 08:49:32 +0000
+++ b/storage/ibmdb2i/db2i_conversion.cc	2010-07-01 15:12:33 +0000
@@ -292,7 +292,7 @@ static void get_field_default_value(Fiel
               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(Fiel
             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(Fiel
             if (field->charset() == &my_charset_bin)
               defaultClause.append(")");              
 
-            my_free(out, MYF(0));
+            my_free(out);
           }
         }
         else

=== modified file 'storage/ibmdb2i/db2i_file.cc'
--- a/storage/ibmdb2i/db2i_file.cc	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_file.cc	2010-07-01 15:12:33 +0000
@@ -280,12 +280,9 @@ void db2i_table::renameAssocFiles(const
 
 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::smartFilenameToTableN
     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));
 }
 

=== modified file 'storage/ibmdb2i/db2i_file.h'
--- a/storage/ibmdb2i/db2i_file.h	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_file.h	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'storage/ibmdb2i/db2i_global.h'
--- a/storage/ibmdb2i/db2i_global.h	2009-02-15 02:18:30 +0000
+++ b/storage/ibmdb2i/db2i_global.h	2010-07-01 15:12:33 +0000
@@ -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*)));
   }  
 }
 

=== modified file 'storage/ibmdb2i/db2i_ileBridge.cc'
--- a/storage/ibmdb2i/db2i_ileBridge.cc	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_ileBridge.cc	2010-07-01 15:12:33 +0000
@@ -1306,7 +1306,7 @@ FILE_HANDLE db2i_ileBridge::PreservedHan
         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;
     }

=== modified file 'storage/ibmdb2i/db2i_ileBridge.h'
--- a/storage/ibmdb2i/db2i_ileBridge.h	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_ileBridge.h	2010-07-01 15:12:33 +0000
@@ -320,7 +320,7 @@ public:
   {
     if (likely(connErrText))
     {
-      my_free(connErrText, MYF(0)); 
+      my_free(connErrText);
       connErrText = NULL;
     }
   }

=== modified file 'storage/ibmdb2i/ha_ibmdb2i.cc'
--- a/storage/ibmdb2i/ha_ibmdb2i.cc	2009-12-22 06:36:04 +0000
+++ b/storage/ibmdb2i/ha_ibmdb2i.cc	2010-07-01 15:12:33 +0000
@@ -404,7 +404,7 @@ IBMDB2I_SHARE *ha_ibmdb2i::get_share(con
 
 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
     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();
 }

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2010-06-17 20:51:35 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2010-07-01 15:12:33 +0000
@@ -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_inf
 	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* s
 		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 */

=== modified file 'storage/myisam/ft_boolean_search.c'
--- a/storage/myisam/ft_boolean_search.c	2010-02-02 11:08:49 +0000
+++ b/storage/myisam/ft_boolean_search.c	2010-07-01 15:12:33 +0000
@@ -608,7 +608,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO
   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 *ft
     delete_tree(& ftb->no_dupes);
   }
   free_root(& ftb->mem_root, MYF(0));
-  my_free((uchar*)ftb,MYF(0));
+  my_free(ftb);
 }
 
 

=== modified file 'storage/myisam/ft_nlq_search.c'
--- a/storage/myisam/ft_nlq_search.c	2010-06-10 20:16:43 +0000
+++ b/storage/myisam/ft_nlq_search.c	2010-07-01 15:12:33 +0000
@@ -357,7 +357,7 @@ float ft_nlq_find_relevance(FT_INFO *han
 
 void ft_nlq_close_search(FT_INFO *handler)
 {
-  my_free((uchar*)handler,MYF(0));
+  my_free(handler);
 }
 
 

=== modified file 'storage/myisam/ft_stopwords.c'
--- a/storage/myisam/ft_stopwords.c	2007-10-11 15:07:40 +0000
+++ b/storage/myisam/ft_stopwords.c	2010-07-01 15:12:33 +0000
@@ -38,7 +38,7 @@ static void FT_STOPWORD_free(FT_STOPWORD
                              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;

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2010-04-19 12:09:44 +0000
+++ b/storage/myisam/ha_myisam.cc	2010-07-01 15:12:33 +0000
@@ -756,7 +756,7 @@ int ha_myisam::open(const char *name, in
     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,
                    records, recinfo,
                    0, (MI_UNIQUEDEF*) 0,
                    &create_info, create_flags);
-  my_free((uchar*) recinfo, MYF(0));
+  my_free(recinfo);
   DBUG_RETURN(error);
 }
 

=== modified file 'storage/myisam/mi_check.c'
--- a/storage/myisam/mi_check.c	2010-06-25 15:32:59 +0000
+++ b/storage/myisam/mi_check.c	2010-07-01 15:12:33 +0000
@@ -1369,12 +1369,12 @@ int chk_data_link(MI_CHECK *param, MI_IN
     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,Fi
       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
     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
       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;
 }

=== modified file 'storage/myisam/mi_close.c'
--- a/storage/myisam/mi_close.c	2009-12-05 01:26:15 +0000
+++ b/storage/myisam/mi_close.c	2010-07-01 15:12:33 +0000
@@ -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)
   {

=== modified file 'storage/myisam/mi_create.c'
--- a/storage/myisam/mi_create.c	2010-05-26 14:12:23 +0000
+++ b/storage/myisam/mi_create.c	2010-07-01 15:12:33 +0000
@@ -834,7 +834,7 @@ int mi_create(const char *name,uint keys
   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 */
 }
 

=== modified file 'storage/myisam/mi_dynrec.c'
--- a/storage/myisam/mi_dynrec.c	2010-04-03 08:37:53 +0000
+++ b/storage/myisam/mi_dynrec.c	2010-07-01 15:12:33 +0000
@@ -44,7 +44,7 @@ static int _mi_cmp_buffer(File file, con
 #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
     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);

=== modified file 'storage/myisam/mi_open.c'
--- a/storage/myisam/mi_open.c	2010-05-28 05:47:58 +0000
+++ b/storage/myisam/mi_open.c	2010-07-01 15:12:33 +0000
@@ -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)

=== modified file 'storage/myisam/mi_packrec.c'
--- a/storage/myisam/mi_packrec.c	2009-12-21 17:38:45 +0000
+++ b/storage/myisam/mi_packrec.c	2010-07-01 15:12:33 +0000
@@ -298,9 +298,9 @@ my_bool _mi_read_pack_info(MI_INFO *info
 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);
 }

=== modified file 'storage/myisam/mi_preload.c'
--- a/storage/myisam/mi_preload.c	2009-12-05 01:26:15 +0000
+++ b/storage/myisam/mi_preload.c	2010-07-01 15:12:33 +0000
@@ -113,11 +113,11 @@ int mi_preload(MI_INFO *info, ulonglong
   }
   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);
 }
 

=== modified file 'storage/myisam/mi_test2.c'
--- a/storage/myisam/mi_test2.c	2009-12-09 11:03:34 +0000
+++ b/storage/myisam/mi_test2.c	2010-07-01 15:12:33 +0000
@@ -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:

=== modified file 'storage/myisam/mi_write.c'
--- a/storage/myisam/mi_write.c	2010-04-02 15:17:43 +0000
+++ b/storage/myisam/mi_write.c	2010-07-01 15:12:33 +0000
@@ -286,7 +286,7 @@ int _mi_ck_write_btree(register MI_INFO
     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;
   }
 }

=== modified file 'storage/myisam/myisamchk.c'
--- a/storage/myisam/myisamchk.c	2010-06-11 01:30:49 +0000
+++ b/storage/myisam/myisamchk.c	2010-07-01 15:12:33 +0000
@@ -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_PAR
   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_PAR
 			    new_file, update_index))
 	goto err;
     }
-    _sanity(__FILE__,__LINE__);
     if (keypos >= endpos ||
 	(key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&keypos,lastkey))
 	== 0)

=== modified file 'storage/myisam/myisamlog.c'
--- a/storage/myisam/myisamlog.c	2010-06-11 01:30:49 +0000
+++ b/storage/myisam/myisamlog.c	2010-07-01 15:12:33 +0000
@@ -616,7 +616,7 @@ static int examine_log(char * file_name,
 	  }
 	}
       }
-      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, r
   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_i
     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;
 }
 

=== modified file 'storage/myisam/myisampack.c'
--- a/storage/myisam/myisampack.c	2010-06-11 01:30:49 +0000
+++ b/storage/myisam/myisampack.c	2010-07-01 15:12:33 +0000
@@ -486,7 +486,7 @@ static my_bool open_isam_files(PACK_MRG_
  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,c
 	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,c
   }
   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,c
     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_que
     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_que
     {
       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 *
 	       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 *hu
       }
       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_C
     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
 	  {
 	    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_len
 
 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 *hu
     */
     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"));

=== modified file 'storage/myisam/rt_index.c'
--- a/storage/myisam/rt_index.c	2010-03-25 11:18:14 +0000
+++ b/storage/myisam/rt_index.c	2010-07-01 15:12:33 +0000
@@ -972,7 +972,7 @@ int rtree_delete(MI_INFO *info, uint key
           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)

=== modified file 'storage/myisam/sort.c'
--- a/storage/myisam/sort.c	2010-04-02 15:17:43 +0000
+++ b/storage/myisam/sort.c	2010-07-01 15:12:33 +0000
@@ -162,7 +162,7 @@ int _create_index_by_sort(MI_SORT_PARAM
       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
   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
         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
 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_p
     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_p
           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_p
                        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;

=== modified file 'storage/myisammrg/ha_myisammrg.cc'
--- a/storage/myisammrg/ha_myisammrg.cc	2010-06-25 15:32:59 +0000
+++ b/storage/myisammrg/ha_myisammrg.cc	2010-07-01 15:12:33 +0000
@@ -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 */
 

=== modified file 'storage/myisammrg/myrg_close.c'
--- a/storage/myisammrg/myrg_close.c	2009-12-05 01:26:15 +0000
+++ b/storage/myisammrg/myrg_close.c	2010-07-01 15:12:33 +0000
@@ -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);

=== modified file 'storage/myisammrg/myrg_open.c'
--- a/storage/myisammrg/myrg_open.c	2010-03-24 15:03:44 +0000
+++ b/storage/myisammrg/myrg_open.c	2010-07-01 15:12:33 +0000
@@ -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 *
   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_in
       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);

=== modified file 'storage/ndb/config/win-lib.am'
--- a/storage/ndb/config/win-lib.am	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/config/win-lib.am	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'storage/ndb/config/win-prg.am'
--- a/storage/ndb/config/win-prg.am	2006-08-21 13:34:29 +0000
+++ b/storage/ndb/config/win-prg.am	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'storage/ndb/include/util/NdbAutoPtr.hpp'
--- a/storage/ndb/include/util/NdbAutoPtr.hpp	2006-12-23 19:20:40 +0000
+++ b/storage/ndb/include/util/NdbAutoPtr.hpp	2010-07-01 15:12:33 +0000
@@ -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

=== modified file 'storage/ndb/src/mgmapi/mgmapi.cpp'
--- a/storage/ndb/src/mgmapi/mgmapi.cpp	2007-08-29 04:30:21 +0000
+++ b/storage/ndb/src/mgmapi/mgmapi.cpp	2010-07-01 15:12:33 +0000
@@ -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 * ha
   }
 #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;
 }

=== modified file 'storage/ndb/src/mgmapi/ndb_logevent.cpp'
--- a/storage/ndb/src/mgmapi/ndb_logevent.cpp	2007-11-14 02:52:29 +0000
+++ b/storage/ndb/src/mgmapi/ndb_logevent.cpp	2010-07-01 15:12:33 +0000
@@ -82,7 +82,7 @@ void ndb_mgm_destroy_logevent_handle(Ndb
   if ( *h )
     close((*h)->socket);
 
-  my_free((char*)* h,MYF(MY_ALLOW_ZERO_PTR));
+  my_free(* h);
   * h = 0;
 }
 

=== modified file 'storage/ndb/test/ndbapi/testIndexStat.cpp'
--- a/storage/ndb/test/ndbapi/testIndexStat.cpp	2007-08-01 07:24:01 +0000
+++ b/storage/ndb/test/ndbapi/testIndexStat.cpp	2010-07-01 15:12:33 +0000
@@ -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;
 }
 

=== modified file 'storage/ndb/tools/restore/consumer_restore.cpp'
--- a/storage/ndb/tools/restore/consumer_restore.cpp	2009-04-16 09:47:21 +0000
+++ b/storage/ndb/tools/restore/consumer_restore.cpp	2010-07-01 15:12:33 +0000
@@ -449,13 +449,13 @@ bool BackupRestore::translate_frm(NdbDic
   }
   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);

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2010-05-31 15:29:54 +0000
+++ b/storage/perfschema/pfs.cc	2010-07-01 15:12:33 +0000
@@ -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_ke
 
   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;
 }
 

=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c	2010-06-11 01:30:49 +0000
+++ b/tests/mysql_client_test.c	2010-07-01 15:12:33 +0000
@@ -19519,7 +19519,7 @@ get_one_option(int optid, const struct m
     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();
 

=== modified file 'tests/thread_test.c'
--- a/tests/thread_test.c	2009-12-16 08:33:54 +0000
+++ b/tests/thread_test.c	2010-07-01 15:12:33 +0000
@@ -150,7 +150,7 @@ get_one_option(int optid, const struct m
   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 */
     }

=== modified file 'vio/test-ssl.c'
--- a/vio/test-ssl.c	2007-05-10 09:59:39 +0000
+++ b/vio/test-ssl.c	2010-07-01 15:12:33 +0000
@@ -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;
 }

=== modified file 'vio/test-sslclient.c'
--- a/vio/test-sslclient.c	2007-05-10 09:59:39 +0000
+++ b/vio/test-sslclient.c	2010-07-01 15:12:33 +0000
@@ -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 */

=== modified file 'vio/test-sslserver.c'
--- a/vio/test-sslserver.c	2007-05-10 09:59:39 +0000
+++ b/vio/test-sslserver.c	2010-07-01 15:12:33 +0000
@@ -139,12 +139,12 @@ main(int argc __attribute__((unused)), c
 
 #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 */

=== modified file 'vio/vio.c'
--- a/vio/vio.c	2009-12-12 20:38:59 +0000
+++ b/vio/vio.c	2010-07-01 15:12:33 +0000
@@ -164,7 +164,7 @@ static void vio_init(Vio* vio, enum enum
 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);
 }
 
 

=== modified file 'vio/viosslfactories.c'
--- a/vio/viosslfactories.c	2009-11-21 12:11:45 +0000
+++ b/vio/viosslfactories.c	2010-07-01 15:12:33 +0000
@@ -224,7 +224,7 @@ new_VioSSLFd(const char *key_file, const
     *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
     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
       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
     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_fil
 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 */

=== modified file 'vio/viotest-ssl.c'
--- a/vio/viotest-ssl.c	2007-05-10 09:59:39 +0000
+++ b/vio/viotest-ssl.c	2010-07-01 15:12:33 +0000
@@ -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;


Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20100701151233-wbwo1bb2r7k6tkxi.bundle
Thread
bzr commit into mysql-trunk-bugfixing branch (davi:3085) Bug#34043Davi Arnaut1 Jul
Re: bzr commit into mysql-trunk-bugfixing branch (davi:3085)Bug#34043Sergei Golubchik1 Jul
  • Re: bzr commit into mysql-trunk-bugfixing branch (davi:3085) Bug#34043Davi Arnaut1 Jul
Re: bzr commit into mysql-trunk-bugfixing branch (davi:3085) Bug#34043Konstantin Osipov8 Jul