Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly slow as it checks all allocated blocks for overrun at each memory management primitive, yielding a almost exponential slowdown for the memory management functions (malloc, realloc, free). The overrun check basically consists of verifying some bytes of a block for certain magic keys, which catches some simple forms of overrun. Another minor problem is violation of aliasing rules and that its own internal list of blocks is prone to corruption. Another issue with safemalloc is rather the maintenance cost as the tool has a significant impact on the server code. Given the magnitude of memory debuggers available nowadays, especially those that are provided with the platform malloc implementation, maintenance of a in-house and largely obsolete memory debugger becomes a burden that is not worth the effort due to its slowness and lack of support for detecting more common forms of heap corruption. Since there are third-party tools that can provide the same functionality at a lower or comparable performance cost, the solution is to simply remove safemalloc. Third-party tools can provide the same functionality at a lower or comparable performance cost. The removal of safemalloc also allows a simplification of the malloc wrappers, removing quite a bit of kludge: redefinition of my_malloc, my_free and the removal of the unused second argument of my_free. Since free() always check whether the supplied pointer is null, redudant checks are also removed. Also, this patch adds unit testing for my_malloc and moves my_realloc implementation into the same file as the other memory allocation primitives.
This commit is contained in:
parent
d4cd1f843d
commit
a10ae35328
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1205,7 +1205,7 @@ int main(int argc,char *argv[])
|
||||
strncmp(link_name, "/dev/null", 10) == 0)
|
||||
{
|
||||
/* The .mysql_history file is a symlink to /dev/null, don't use it */
|
||||
my_free(histfile, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(histfile);
|
||||
histfile= 0;
|
||||
}
|
||||
}
|
||||
@ -1266,23 +1266,23 @@ sig_handler mysql_end(int sig)
|
||||
glob_buffer.free();
|
||||
old_buffer.free();
|
||||
processed_prompt.free();
|
||||
my_free(server_version,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_mysql_unix_port,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(histfile,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(histfile_tmp,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_host,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(full_username,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(part_username,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(default_prompt,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(server_version);
|
||||
my_free(opt_password);
|
||||
my_free(opt_mysql_unix_port);
|
||||
my_free(histfile);
|
||||
my_free(histfile_tmp);
|
||||
my_free(current_db);
|
||||
my_free(current_host);
|
||||
my_free(current_user);
|
||||
my_free(full_username);
|
||||
my_free(part_username);
|
||||
my_free(default_prompt);
|
||||
#ifdef HAVE_SMEM
|
||||
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(shared_memory_base_name);
|
||||
#endif
|
||||
my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_prompt);
|
||||
while (embedded_server_arg_count > 1)
|
||||
my_free(embedded_server_args[--embedded_server_arg_count],MYF(0));
|
||||
my_free(embedded_server_args[--embedded_server_arg_count]);
|
||||
mysql_server_end();
|
||||
free_defaults(defaults_argv);
|
||||
my_end(my_end_arg);
|
||||
@ -1736,7 +1736,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
if (argument)
|
||||
{
|
||||
char *start= argument;
|
||||
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
opt_password= my_strdup(argument, MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; // Destroy argument
|
||||
if (*start)
|
||||
@ -1833,7 +1833,7 @@ static int get_options(int argc, char **argv)
|
||||
if (argc == 1)
|
||||
{
|
||||
skip_updates= 0;
|
||||
my_free(current_db, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_db);
|
||||
current_db= my_strdup(*argv, MYF(MY_WME));
|
||||
}
|
||||
if (tty_password)
|
||||
@ -2731,7 +2731,7 @@ static void get_current_db()
|
||||
{
|
||||
MYSQL_RES *res;
|
||||
|
||||
my_free(current_db, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_db);
|
||||
current_db= NULL;
|
||||
/* In case of error below current_db will be NULL */
|
||||
if (!mysql_query(&mysql, "SELECT DATABASE()") &&
|
||||
@ -4023,12 +4023,12 @@ com_connect(String *buffer, char *line)
|
||||
tmp= get_arg(buff, 0);
|
||||
if (tmp && *tmp)
|
||||
{
|
||||
my_free(current_db, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_db);
|
||||
current_db= my_strdup(tmp, MYF(MY_WME));
|
||||
tmp= get_arg(buff, 1);
|
||||
if (tmp)
|
||||
{
|
||||
my_free(current_host,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_host);
|
||||
current_host=my_strdup(tmp,MYF(MY_WME));
|
||||
}
|
||||
}
|
||||
@ -4200,7 +4200,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
|
||||
if (mysql_select_db(&mysql,tmp))
|
||||
return put_error(&mysql);
|
||||
}
|
||||
my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_db);
|
||||
current_db=my_strdup(tmp,MYF(MY_WME));
|
||||
#ifdef HAVE_READLINE
|
||||
if (select_db > 1)
|
||||
@ -4952,8 +4952,8 @@ static void add_int_to_prompt(int toadd)
|
||||
|
||||
static void init_username()
|
||||
{
|
||||
my_free(full_username,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(part_username,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(full_username);
|
||||
my_free(part_username);
|
||||
|
||||
MYSQL_RES *result;
|
||||
LINT_INIT(result);
|
||||
@ -4971,7 +4971,7 @@ static int com_prompt(String *buffer, char *line)
|
||||
{
|
||||
char *ptr=strchr(line, ' ');
|
||||
prompt_counter = 0;
|
||||
my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_prompt);
|
||||
current_prompt=my_strdup(ptr ? ptr+1 : default_prompt,MYF(MY_WME));
|
||||
if (!ptr)
|
||||
tee_fprintf(stdout, "Returning to default PROMPT of %s\n", default_prompt);
|
||||
|
@ -236,7 +236,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
if (argument)
|
||||
{
|
||||
char *start=argument;
|
||||
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
opt_password=my_strdup(argument,MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
if (*start)
|
||||
@ -448,10 +448,10 @@ int main(int argc,char *argv[])
|
||||
} /* got connection */
|
||||
|
||||
mysql_close(&mysql);
|
||||
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
my_free(user);
|
||||
#ifdef HAVE_SMEM
|
||||
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(shared_memory_base_name);
|
||||
#endif
|
||||
free_defaults(save_argv);
|
||||
my_end(my_end_arg);
|
||||
@ -1008,8 +1008,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
|
||||
/* free up memory from prompted password */
|
||||
if (typed_password != argv[1])
|
||||
{
|
||||
my_free(typed_password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(verified,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(typed_password);
|
||||
my_free(verified);
|
||||
}
|
||||
argc--; argv++;
|
||||
break;
|
||||
|
@ -68,20 +68,20 @@ TYPELIB base64_output_mode_typelib=
|
||||
{ array_elements(base64_output_mode_names) - 1, "",
|
||||
base64_output_mode_names, NULL };
|
||||
static enum_base64_output_mode opt_base64_output_mode= BASE64_OUTPUT_UNSPEC;
|
||||
static const char *opt_base64_output_mode_str= NullS;
|
||||
static const char* database= 0;
|
||||
static char *opt_base64_output_mode_str= NullS;
|
||||
static char* database= 0;
|
||||
static my_bool force_opt= 0, short_form= 0, remote_opt= 0;
|
||||
static my_bool debug_info_flag, debug_check_flag;
|
||||
static my_bool force_if_open_opt= 1;
|
||||
static ulonglong offset = 0;
|
||||
static const char* host = 0;
|
||||
static char* host = 0;
|
||||
static int port= 0;
|
||||
static uint my_end_arg;
|
||||
static const char* sock= 0;
|
||||
#ifdef HAVE_SMEM
|
||||
static char *shared_memory_base_name= 0;
|
||||
#endif
|
||||
static const char* user = 0;
|
||||
static char* user = 0;
|
||||
static char* pass = 0;
|
||||
static char *charset= 0;
|
||||
|
||||
@ -96,7 +96,7 @@ static my_time_t start_datetime= 0, stop_datetime= MY_TIME_T_MAX;
|
||||
static ulonglong rec_count= 0;
|
||||
static short binlog_flags = 0;
|
||||
static MYSQL* mysql = NULL;
|
||||
static const char* dirname_for_local_load= 0;
|
||||
static char* dirname_for_local_load= 0;
|
||||
|
||||
/**
|
||||
Pointer to the Format_description_log_event of the currently active binlog.
|
||||
@ -191,7 +191,7 @@ public:
|
||||
int init()
|
||||
{
|
||||
return init_dynamic_array(&file_names, sizeof(File_name_record),
|
||||
100,100 CALLER_INFO);
|
||||
100, 100);
|
||||
}
|
||||
|
||||
void init_by_dir_name(const char *dir)
|
||||
@ -213,7 +213,7 @@ public:
|
||||
{
|
||||
if (ptr->fname)
|
||||
{
|
||||
my_free(ptr->fname, MYF(MY_WME));
|
||||
my_free(ptr->fname);
|
||||
delete ptr->event;
|
||||
bzero((char *)ptr, sizeof(File_name_record));
|
||||
}
|
||||
@ -442,7 +442,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
|
||||
{
|
||||
error("Could not construct local filename %s%s.",
|
||||
target_dir_name,bname);
|
||||
my_free(fname, MYF(0));
|
||||
my_free(fname);
|
||||
delete ce;
|
||||
DBUG_RETURN(ERROR_STOP);
|
||||
}
|
||||
@ -458,7 +458,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
|
||||
if (set_dynamic(&file_names, (uchar*)&rec, file_id))
|
||||
{
|
||||
error("Out of memory.");
|
||||
my_free(fname, MYF(0));
|
||||
my_free(fname);
|
||||
delete ce;
|
||||
DBUG_RETURN(ERROR_STOP);
|
||||
}
|
||||
@ -822,7 +822,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
||||
*/
|
||||
convert_path_to_forward_slashes((char*) ce->fname);
|
||||
ce->print(result_file, print_event_info, TRUE);
|
||||
my_free((char*)ce->fname,MYF(MY_WME));
|
||||
my_free((void*)ce->fname);
|
||||
delete ce;
|
||||
}
|
||||
else
|
||||
@ -887,7 +887,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
|
||||
}
|
||||
|
||||
if (fname)
|
||||
my_free(fname, MYF(MY_WME));
|
||||
my_free(fname);
|
||||
break;
|
||||
}
|
||||
case TABLE_MAP_EVENT:
|
||||
@ -1222,11 +1222,11 @@ static void warning(const char *format,...)
|
||||
*/
|
||||
static void cleanup()
|
||||
{
|
||||
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((char*) database, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((char*) host, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((char*) user, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((char*) dirname_for_local_load, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(pass);
|
||||
my_free(database);
|
||||
my_free(host);
|
||||
my_free(user);
|
||||
my_free(dirname_for_local_load);
|
||||
|
||||
delete glob_description_event;
|
||||
if (mysql)
|
||||
@ -1306,7 +1306,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
argument= (char*) ""; // Don't require password
|
||||
if (argument)
|
||||
{
|
||||
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(pass);
|
||||
char *start=argument;
|
||||
pass= my_strdup(argument,MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
|
@ -291,7 +291,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
if (argument)
|
||||
{
|
||||
char *start = argument;
|
||||
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
opt_password = my_strdup(argument, MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
if (*start)
|
||||
@ -470,7 +470,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
|
||||
}
|
||||
*--end = 0;
|
||||
handle_request_for_tables(table_names_comma_sep + 1, (uint) (tot_length - 1));
|
||||
my_free(table_names_comma_sep, MYF(0));
|
||||
my_free(table_names_comma_sep);
|
||||
}
|
||||
else
|
||||
for (; tables > 0; tables--, table_names++)
|
||||
@ -569,7 +569,7 @@ static int process_all_tables_in_db(char *database)
|
||||
*--end = 0;
|
||||
if (tot_length)
|
||||
handle_request_for_tables(tables + 1, tot_length - 1);
|
||||
my_free(tables, MYF(0));
|
||||
my_free(tables);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -727,7 +727,7 @@ static int handle_request_for_tables(char *tables, uint length)
|
||||
return 1;
|
||||
}
|
||||
print_result();
|
||||
my_free(query, MYF(0));
|
||||
my_free(query);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -899,9 +899,9 @@ int main(int argc, char **argv)
|
||||
dbDisconnect(current_host);
|
||||
if (opt_auto_repair)
|
||||
delete_dynamic(&tables4repair);
|
||||
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
#ifdef HAVE_SMEM
|
||||
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(shared_memory_base_name);
|
||||
#endif
|
||||
my_end(my_end_arg);
|
||||
return(first_error!=0);
|
||||
|
@ -715,12 +715,6 @@ static void write_footer(FILE *sql_file)
|
||||
} /* write_footer */
|
||||
|
||||
|
||||
static void free_table_ent(char *key)
|
||||
{
|
||||
my_free(key, MYF(0));
|
||||
}
|
||||
|
||||
|
||||
uchar* get_table_key(const char *entry, size_t *length,
|
||||
my_bool not_used __attribute__((unused)))
|
||||
{
|
||||
@ -745,7 +739,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
if (argument)
|
||||
{
|
||||
char *start=argument;
|
||||
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
opt_password=my_strdup(argument,MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
if (*start)
|
||||
@ -905,8 +899,7 @@ static int get_options(int *argc, char ***argv)
|
||||
defaults_argv= *argv;
|
||||
|
||||
if (my_hash_init(&ignore_table, charset_info, 16, 0, 0,
|
||||
(my_hash_get_key) get_table_key,
|
||||
(my_hash_free_key) free_table_ent, 0))
|
||||
(my_hash_get_key) get_table_key, my_free, 0))
|
||||
return(EX_EOM);
|
||||
/* Don't copy internal log tables */
|
||||
if (my_hash_insert(&ignore_table,
|
||||
@ -1420,7 +1413,7 @@ static void free_resources()
|
||||
{
|
||||
if (md_result_file && md_result_file != stdout)
|
||||
my_fclose(md_result_file, MYF(0));
|
||||
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
if (my_hash_inited(&ignore_table))
|
||||
my_hash_free(&ignore_table);
|
||||
if (extended_insert)
|
||||
@ -1534,7 +1527,7 @@ static void unescape(FILE *file,char *pos,uint length)
|
||||
fputs(tmp, file);
|
||||
fputc('\'', file);
|
||||
check_io(file);
|
||||
my_free(tmp, MYF(MY_WME));
|
||||
my_free(tmp);
|
||||
DBUG_VOID_RETURN;
|
||||
} /* unescape */
|
||||
|
||||
@ -2201,7 +2194,7 @@ static uint dump_routines_for_db(char *db)
|
||||
}
|
||||
}
|
||||
|
||||
my_free(query_str, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(query_str);
|
||||
}
|
||||
} /* end of routine printing */
|
||||
mysql_free_result(routine_res);
|
||||
@ -2374,12 +2367,12 @@ static uint get_table_structure(char *table, char *db, char *table_type,
|
||||
if (mysql_errno(mysql) == ER_VIEW_INVALID)
|
||||
fprintf(sql_file, "\n-- failed on view %s: %s\n\n", result_table, scv_buff ? scv_buff : "");
|
||||
|
||||
my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(scv_buff);
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
else
|
||||
my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(scv_buff);
|
||||
|
||||
if (mysql_num_rows(result))
|
||||
{
|
||||
@ -2855,7 +2848,7 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
my_free(query_str, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(query_str);
|
||||
}
|
||||
|
||||
DBUG_RETURN(FALSE);
|
||||
@ -4073,7 +4066,7 @@ static int dump_all_tables_in_db(char *database)
|
||||
if (include_table((uchar*) hash_key, end - hash_key))
|
||||
{
|
||||
dump_table(table,database);
|
||||
my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(order_by);
|
||||
order_by= 0;
|
||||
if (opt_dump_triggers && ! opt_xml &&
|
||||
mysql_get_server_version(mysql) >= 50009)
|
||||
@ -4345,7 +4338,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
|
||||
dump_routines_for_db(db);
|
||||
}
|
||||
free_root(&root, MYF(0));
|
||||
my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(order_by);
|
||||
order_by= 0;
|
||||
if (opt_xml)
|
||||
{
|
||||
@ -5258,7 +5251,7 @@ int main(int argc, char **argv)
|
||||
goto err;
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(shared_memory_base_name);
|
||||
#endif
|
||||
/*
|
||||
No reason to explicitely COMMIT the transaction, neither to explicitely
|
||||
|
@ -230,7 +230,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
if (argument)
|
||||
{
|
||||
char *start=argument;
|
||||
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
opt_password=my_strdup(argument,MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
if (*start)
|
||||
@ -684,9 +684,9 @@ int main(int argc, char **argv)
|
||||
exitcode= error;
|
||||
db_disconnect(current_host, mysql);
|
||||
}
|
||||
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
#ifdef HAVE_SMEM
|
||||
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(shared_memory_base_name);
|
||||
#endif
|
||||
free_defaults(argv_to_free);
|
||||
my_end(my_end_arg);
|
||||
|
@ -149,10 +149,9 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
mysql_close(&mysql); /* Close & free connection */
|
||||
if (opt_password)
|
||||
my_free(opt_password,MYF(0));
|
||||
my_free(opt_password);
|
||||
#ifdef HAVE_SMEM
|
||||
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(shared_memory_base_name);
|
||||
#endif
|
||||
my_end(my_end_arg);
|
||||
exit(error ? 1 : 0);
|
||||
@ -292,7 +291,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
if (argument)
|
||||
{
|
||||
char *start=argument;
|
||||
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
opt_password=my_strdup(argument,MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
if (*start)
|
||||
|
@ -399,10 +399,8 @@ int main(int argc, char **argv)
|
||||
mysql_close(&mysql); /* Close & free connection */
|
||||
|
||||
/* now free all the strings we created */
|
||||
if (opt_password)
|
||||
my_free(opt_password, MYF(0));
|
||||
|
||||
my_free(concurrency, MYF(0));
|
||||
my_free(opt_password);
|
||||
my_free(concurrency);
|
||||
|
||||
statement_cleanup(create_statements);
|
||||
statement_cleanup(query_statements);
|
||||
@ -411,8 +409,7 @@ int main(int argc, char **argv)
|
||||
option_cleanup(engine_options);
|
||||
|
||||
#ifdef HAVE_SMEM
|
||||
if (shared_memory_base_name)
|
||||
my_free(shared_memory_base_name, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(shared_memory_base_name);
|
||||
#endif
|
||||
free_defaults(defaults_argv);
|
||||
my_end(my_end_arg);
|
||||
@ -504,7 +501,7 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
|
||||
if (opt_csv_str)
|
||||
print_conclusions_csv(&conclusion);
|
||||
|
||||
my_free(head_sptr, MYF(0));
|
||||
my_free(head_sptr);
|
||||
|
||||
}
|
||||
|
||||
@ -721,7 +718,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
if (argument)
|
||||
{
|
||||
char *start= argument;
|
||||
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_password);
|
||||
opt_password= my_strdup(argument,MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
if (*start)
|
||||
@ -1367,7 +1364,7 @@ get_options(int *argc,char ***argv)
|
||||
tmp_string[sbuf.st_size]= '\0';
|
||||
my_close(data_file,MYF(0));
|
||||
parse_delimiter(tmp_string, &create_statements, delimiter[0]);
|
||||
my_free(tmp_string, MYF(0));
|
||||
my_free(tmp_string);
|
||||
}
|
||||
else if (create_string)
|
||||
{
|
||||
@ -1396,7 +1393,7 @@ get_options(int *argc,char ***argv)
|
||||
if (user_supplied_query)
|
||||
actual_queries= parse_delimiter(tmp_string, &query_statements,
|
||||
delimiter[0]);
|
||||
my_free(tmp_string, MYF(0));
|
||||
my_free(tmp_string);
|
||||
}
|
||||
else if (user_supplied_query)
|
||||
{
|
||||
@ -1427,7 +1424,7 @@ get_options(int *argc,char ***argv)
|
||||
if (user_supplied_pre_statements)
|
||||
(void)parse_delimiter(tmp_string, &pre_statements,
|
||||
delimiter[0]);
|
||||
my_free(tmp_string, MYF(0));
|
||||
my_free(tmp_string);
|
||||
}
|
||||
else if (user_supplied_pre_statements)
|
||||
{
|
||||
@ -1458,7 +1455,7 @@ get_options(int *argc,char ***argv)
|
||||
if (user_supplied_post_statements)
|
||||
(void)parse_delimiter(tmp_string, &post_statements,
|
||||
delimiter[0]);
|
||||
my_free(tmp_string, MYF(0));
|
||||
my_free(tmp_string);
|
||||
}
|
||||
else if (user_supplied_post_statements)
|
||||
{
|
||||
@ -1555,9 +1552,9 @@ drop_primary_key_list(void)
|
||||
if (primary_keys_number_of)
|
||||
{
|
||||
for (counter= 0; counter < primary_keys_number_of; counter++)
|
||||
my_free(primary_keys[counter], MYF(0));
|
||||
my_free(primary_keys[counter]);
|
||||
|
||||
my_free(primary_keys, MYF(0));
|
||||
my_free(primary_keys);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -2154,11 +2151,9 @@ option_cleanup(option_string *stmt)
|
||||
for (ptr= stmt; ptr; ptr= nptr)
|
||||
{
|
||||
nptr= ptr->next;
|
||||
if (ptr->string)
|
||||
my_free(ptr->string, MYF(0));
|
||||
if (ptr->option)
|
||||
my_free(ptr->option, MYF(0));
|
||||
my_free(ptr, MYF(0));
|
||||
my_free(ptr->string);
|
||||
my_free(ptr->option);
|
||||
my_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2172,9 +2167,8 @@ statement_cleanup(statement *stmt)
|
||||
for (ptr= stmt; ptr; ptr= nptr)
|
||||
{
|
||||
nptr= ptr->next;
|
||||
if (ptr->string)
|
||||
my_free(ptr->string, MYF(0));
|
||||
my_free(ptr, MYF(0));
|
||||
my_free(ptr->string);
|
||||
my_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,10 +84,10 @@ static my_bool get_one_option(int optid, const struct my_option *,
|
||||
C_MODE_END
|
||||
|
||||
enum {
|
||||
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
|
||||
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
|
||||
OPT_MAX_CONNECT_RETRIES, OPT_MAX_CONNECTIONS, OPT_MARK_PROGRESS,
|
||||
OPT_LOG_DIR, OPT_TAIL_LINES, OPT_RESULT_FORMAT_VERSION
|
||||
OPT_PS_PROTOCOL=OPT_MAX_CLIENT_OPTION, OPT_SP_PROTOCOL,
|
||||
OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, OPT_MAX_CONNECT_RETRIES,
|
||||
OPT_MAX_CONNECTIONS, OPT_MARK_PROGRESS, OPT_LOG_DIR,
|
||||
OPT_TAIL_LINES, OPT_RESULT_FORMAT_VERSION
|
||||
};
|
||||
|
||||
static int record= 0, opt_sleep= -1;
|
||||
@ -156,7 +156,7 @@ static struct st_block *cur_block, *block_stack_end;
|
||||
struct st_test_file
|
||||
{
|
||||
FILE* file;
|
||||
const char *file_name;
|
||||
char *file_name;
|
||||
uint lineno; /* Current line in file */
|
||||
};
|
||||
|
||||
@ -1106,9 +1106,9 @@ void close_connections()
|
||||
mysql_close(&next_con->mysql);
|
||||
if (next_con->util_mysql)
|
||||
mysql_close(next_con->util_mysql);
|
||||
my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(next_con->name);
|
||||
}
|
||||
my_free(connections, MYF(MY_WME));
|
||||
my_free(connections);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@ -1137,7 +1137,7 @@ void close_files()
|
||||
DBUG_PRINT("info", ("closing file: %s", cur_file->file_name));
|
||||
fclose(cur_file->file);
|
||||
}
|
||||
my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(cur_file->file_name);
|
||||
cur_file->file_name= 0;
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
@ -1157,22 +1157,22 @@ void free_used_memory()
|
||||
for (i= 0 ; i < q_lines.elements ; i++)
|
||||
{
|
||||
struct st_command **q= dynamic_element(&q_lines, i, struct st_command**);
|
||||
my_free((*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((*q)->query_buf);
|
||||
if ((*q)->content.str)
|
||||
dynstr_free(&(*q)->content);
|
||||
my_free((*q),MYF(0));
|
||||
my_free((*q));
|
||||
}
|
||||
for (i= 0; i < 10; i++)
|
||||
{
|
||||
if (var_reg[i].alloced_len)
|
||||
my_free(var_reg[i].str_val, MYF(MY_WME));
|
||||
my_free(var_reg[i].str_val);
|
||||
}
|
||||
while (embedded_server_arg_count > 1)
|
||||
my_free(embedded_server_args[--embedded_server_arg_count],MYF(0));
|
||||
my_free(embedded_server_args[--embedded_server_arg_count]);
|
||||
delete_dynamic(&q_lines);
|
||||
dynstr_free(&ds_res);
|
||||
free_all_replace();
|
||||
my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_pass);
|
||||
free_defaults(default_argv);
|
||||
free_re();
|
||||
#ifdef __WIN__
|
||||
@ -1933,9 +1933,10 @@ static uchar *get_var_key(const uchar* var, size_t *len,
|
||||
|
||||
static void var_free(void *v)
|
||||
{
|
||||
my_free(((VAR*) v)->str_val, MYF(MY_WME));
|
||||
if (((VAR*)v)->alloced)
|
||||
my_free(v, MYF(MY_WME));
|
||||
VAR *var= (VAR*) v;
|
||||
my_free(var->str_val);
|
||||
if (var->alloced)
|
||||
my_free(var);
|
||||
}
|
||||
|
||||
C_MODE_END
|
||||
@ -4824,7 +4825,7 @@ void do_close_connection(struct st_command *command)
|
||||
con->util_mysql= 0;
|
||||
con->pending= FALSE;
|
||||
|
||||
my_free(con->name, MYF(0));
|
||||
my_free(con->name);
|
||||
|
||||
/*
|
||||
When the connection is closed set name to "-closed_connection-"
|
||||
@ -5491,7 +5492,7 @@ int read_line(char *buf, int size)
|
||||
fclose(cur_file->file);
|
||||
cur_file->file= 0;
|
||||
}
|
||||
my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(cur_file->file_name);
|
||||
cur_file->file_name= 0;
|
||||
if (cur_file == file_stack)
|
||||
{
|
||||
@ -5967,9 +5968,6 @@ static struct my_option my_long_options[] =
|
||||
0, 0, 0},
|
||||
{"silent", 's', "Suppress all normal output. Synonym for --quiet.",
|
||||
&silent, &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"skip-safemalloc", OPT_SKIP_SAFEMALLOC,
|
||||
"Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"sleep", 'T', "Always sleep this many seconds on sleep commands.",
|
||||
&opt_sleep, &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, -1, 0,
|
||||
0, 0, 0},
|
||||
@ -6125,7 +6123,7 @@ get_one_option(int optid, const struct my_option *, char *argument)
|
||||
argument= (char*) ""; // Don't require password
|
||||
if (argument)
|
||||
{
|
||||
my_free(opt_pass, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(opt_pass);
|
||||
opt_pass= my_strdup(argument, MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
tty_password= 0;
|
||||
@ -6158,11 +6156,6 @@ get_one_option(int optid, const struct my_option *, char *argument)
|
||||
case 'F':
|
||||
read_embedded_server_arguments(argument);
|
||||
break;
|
||||
case OPT_SKIP_SAFEMALLOC:
|
||||
#ifdef SAFEMALLOC
|
||||
sf_malloc_quick=1;
|
||||
#endif
|
||||
break;
|
||||
case OPT_RESULT_FORMAT_VERSION:
|
||||
set_result_format_version(opt_result_format_version);
|
||||
break;
|
||||
@ -6321,7 +6314,7 @@ void init_win_path_patterns()
|
||||
/* Don't insert zero length strings in patterns array */
|
||||
if (strlen(p) == 0)
|
||||
{
|
||||
my_free(p, MYF(0));
|
||||
my_free(p);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -6345,7 +6338,7 @@ void free_win_path_patterns()
|
||||
for (i=0 ; i < patterns.elements ; i++)
|
||||
{
|
||||
const char** pattern= dynamic_element(&patterns, i, const char**);
|
||||
my_free((char*) *pattern, MYF(0));
|
||||
my_free(*pattern);
|
||||
}
|
||||
delete_dynamic(&patterns);
|
||||
}
|
||||
@ -6538,12 +6531,12 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
|
||||
for (i= 0; i < num_fields; i++)
|
||||
{
|
||||
/* Free data for output */
|
||||
my_free(my_bind[i].buffer, MYF(MY_WME | MY_FAE));
|
||||
my_free(my_bind[i].buffer);
|
||||
}
|
||||
/* Free array with bind structs, lengths and NULL flags */
|
||||
my_free(my_bind , MYF(MY_WME | MY_FAE));
|
||||
my_free(length , MYF(MY_WME | MY_FAE));
|
||||
my_free(is_null , MYF(MY_WME | MY_FAE));
|
||||
my_free(my_bind);
|
||||
my_free(length);
|
||||
my_free(is_null);
|
||||
}
|
||||
|
||||
|
||||
@ -8489,11 +8482,11 @@ void do_get_replace_column(struct st_command *command)
|
||||
if (!*from)
|
||||
die("Wrong number of arguments to replace_column in '%s'", command->query);
|
||||
to= get_string(&buff, &from, command);
|
||||
my_free(replace_column[column_number-1], MY_ALLOW_ZERO_PTR);
|
||||
my_free(replace_column[column_number-1]);
|
||||
replace_column[column_number-1]= my_strdup(to, MYF(MY_WME | MY_FAE));
|
||||
set_if_bigger(max_replace_column, column_number);
|
||||
}
|
||||
my_free(start, MYF(0));
|
||||
my_free(start);
|
||||
command->last_argument= command->end;
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
@ -8507,7 +8500,7 @@ void free_replace_column()
|
||||
{
|
||||
if (replace_column[i])
|
||||
{
|
||||
my_free(replace_column[i], 0);
|
||||
my_free(replace_column[i]);
|
||||
replace_column[i]= 0;
|
||||
}
|
||||
}
|
||||
@ -8588,7 +8581,7 @@ void do_get_replace(struct st_command *command)
|
||||
die("Can't initialize replace from '%s'", command->query);
|
||||
free_pointer_array(&from_array);
|
||||
free_pointer_array(&to_array);
|
||||
my_free(start, MYF(0));
|
||||
my_free(start);
|
||||
command->last_argument= command->end;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -8597,11 +8590,8 @@ void do_get_replace(struct st_command *command)
|
||||
void free_replace()
|
||||
{
|
||||
DBUG_ENTER("free_replace");
|
||||
if (glob_replace)
|
||||
{
|
||||
my_free(glob_replace,MYF(0));
|
||||
glob_replace=0;
|
||||
}
|
||||
my_free(glob_replace);
|
||||
glob_replace= NULL;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@ -8821,7 +8811,7 @@ struct st_replace_regex* init_replace_regex(char* expr)
|
||||
return res;
|
||||
|
||||
err:
|
||||
my_free(res,0);
|
||||
my_free(res);
|
||||
die("Error parsing replace_regex \"%s\"", expr);
|
||||
return 0;
|
||||
}
|
||||
@ -8913,9 +8903,9 @@ void free_replace_regex()
|
||||
if (glob_replace_regex)
|
||||
{
|
||||
delete_dynamic(&glob_replace_regex->regex_arr);
|
||||
my_free(glob_replace_regex->even_buf,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(glob_replace_regex->odd_buf,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(glob_replace_regex,MYF(0));
|
||||
my_free(glob_replace_regex->even_buf);
|
||||
my_free(glob_replace_regex->odd_buf);
|
||||
my_free(glob_replace_regex);
|
||||
glob_replace_regex=0;
|
||||
}
|
||||
}
|
||||
@ -9110,7 +9100,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
|
||||
str_p= str_end;
|
||||
}
|
||||
}
|
||||
my_free(subs, MYF(0));
|
||||
my_free(subs);
|
||||
my_regfree(&r);
|
||||
*res_p= 0;
|
||||
*buf_p= buf;
|
||||
@ -9242,7 +9232,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
|
||||
if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME))))
|
||||
{
|
||||
free_sets(&sets);
|
||||
my_free(found_set,MYF(0));
|
||||
my_free(found_set);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@ -9437,9 +9427,9 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
|
||||
replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1));
|
||||
}
|
||||
}
|
||||
my_free(follow,MYF(0));
|
||||
my_free(follow);
|
||||
free_sets(&sets);
|
||||
my_free(found_set,MYF(0));
|
||||
my_free(found_set);
|
||||
DBUG_PRINT("exit",("Replace table has %d states",sets.count));
|
||||
DBUG_RETURN(replace);
|
||||
}
|
||||
@ -9455,7 +9445,7 @@ int init_sets(REP_SETS *sets,uint states)
|
||||
if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits*
|
||||
SET_MALLOC_HUNC,MYF(MY_WME))))
|
||||
{
|
||||
my_free(sets->set,MYF(0));
|
||||
my_free(sets->set);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -9516,8 +9506,8 @@ void free_last_set(REP_SETS *sets)
|
||||
|
||||
void free_sets(REP_SETS *sets)
|
||||
{
|
||||
my_free(sets->set_buffer,MYF(0));
|
||||
my_free(sets->bit_buffer,MYF(0));
|
||||
my_free(sets->set_buffer);
|
||||
my_free(sets->bit_buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -9657,7 +9647,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
|
||||
if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
|
||||
MYF(MY_WME))))
|
||||
{
|
||||
my_free((char*) pa->typelib.type_names,MYF(0));
|
||||
my_free(pa->typelib.type_names);
|
||||
DBUG_RETURN (-1);
|
||||
}
|
||||
pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
|
||||
@ -9718,9 +9708,9 @@ void free_pointer_array(POINTER_ARRAY *pa)
|
||||
if (pa->typelib.count)
|
||||
{
|
||||
pa->typelib.count=0;
|
||||
my_free((char*) pa->typelib.type_names,MYF(0));
|
||||
my_free(pa->typelib.type_names);
|
||||
pa->typelib.type_names=0;
|
||||
my_free(pa->str,MYF(0));
|
||||
my_free(pa->str);
|
||||
}
|
||||
} /* free_pointer_array */
|
||||
|
||||
|
@ -35,7 +35,7 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
|
||||
return 0;
|
||||
if (init_line_buffer(line_buff,my_fileno(file),IO_SIZE,max_size))
|
||||
{
|
||||
my_free(line_buff,MYF(0));
|
||||
my_free(line_buff);
|
||||
return 0;
|
||||
}
|
||||
return line_buff;
|
||||
@ -63,8 +63,8 @@ void batch_readline_end(LINE_BUFFER *line_buff)
|
||||
{
|
||||
if (line_buff)
|
||||
{
|
||||
my_free(line_buff->buffer,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(line_buff,MYF(0));
|
||||
my_free(line_buff->buffer);
|
||||
my_free(line_buff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, char * str)
|
||||
return 0;
|
||||
if (init_line_buffer_from_string(line_buff,str))
|
||||
{
|
||||
my_free(line_buff,MYF(0));
|
||||
my_free(line_buff);
|
||||
return 0;
|
||||
}
|
||||
return line_buff;
|
||||
|
@ -175,7 +175,7 @@ public:
|
||||
{
|
||||
alloced=0;
|
||||
Alloced_length=0;
|
||||
my_free(Ptr,MYF(0));
|
||||
my_free(Ptr);
|
||||
Ptr=0;
|
||||
str_length=0; /* Safety */
|
||||
}
|
||||
|
@ -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])
|
||||
|
@ -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)
|
||||
|
@ -19,7 +19,7 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
|
||||
LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
|
||||
pkglib_LIBRARIES = libdbug.a
|
||||
noinst_HEADERS = dbug_long.h
|
||||
libdbug_a_SOURCES = dbug.c sanity.c
|
||||
libdbug_a_SOURCES = dbug.c
|
||||
EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
|
||||
user.r monty.doc dbug_add_tags.pl \
|
||||
my_main.c main.c factorial.c dbug_analyze.c \
|
||||
|
23
dbug/dbug.c
23
dbug/dbug.c
@ -128,9 +128,8 @@
|
||||
#define PROFILE_ON (1 << 7) /* Print out profiling code */
|
||||
#define PID_ON (1 << 8) /* Identify each line with process id */
|
||||
#define TIMESTAMP_ON (1 << 9) /* timestamp every line of output */
|
||||
#define SANITY_CHECK_ON (1 << 10) /* Check safemalloc on DBUG_ENTER */
|
||||
#define FLUSH_ON_WRITE (1 << 11) /* Flush on every write */
|
||||
#define OPEN_APPEND (1 << 12) /* Open for append */
|
||||
#define FLUSH_ON_WRITE (1 << 10) /* Flush on every write */
|
||||
#define OPEN_APPEND (1 << 11) /* Open for append */
|
||||
#define TRACE_ON ((uint)1 << 31) /* Trace enabled. MUST be the highest bit!*/
|
||||
|
||||
#define TRACING (cs->stack->flags & TRACE_ON)
|
||||
@ -184,12 +183,6 @@
|
||||
static void perror(); /* Fake system/library error print routine */
|
||||
#endif
|
||||
|
||||
#ifdef SAFEMALLOC
|
||||
IMPORT int _sanity(const char *file,uint line); /* safemalloc sanity checker */
|
||||
#else
|
||||
#define _sanity(X,Y) (1)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The user may specify a list of functions to trace or
|
||||
* debug. These lists are kept in a linear linked list,
|
||||
@ -705,12 +698,6 @@ int DbugParse(CODE_STATE *cs, const char *control)
|
||||
else
|
||||
stack->flags |= TIMESTAMP_ON;
|
||||
break;
|
||||
case 'S':
|
||||
if (sign < 0)
|
||||
stack->flags &= ~SANITY_CHECK_ON;
|
||||
else
|
||||
stack->flags |= SANITY_CHECK_ON;
|
||||
break;
|
||||
}
|
||||
if (!*end)
|
||||
break;
|
||||
@ -1069,7 +1056,6 @@ int _db_explain_ (CODE_STATE *cs, char *buf, size_t len)
|
||||
op_bool_to_buf('r', cs->stack->sub_level != 0);
|
||||
op_intf_to_buf('t', cs->stack->maxdepth, MAXDEPTH, TRACING);
|
||||
op_bool_to_buf('T', cs->stack->flags & TIMESTAMP_ON);
|
||||
op_bool_to_buf('S', cs->stack->flags & SANITY_CHECK_ON);
|
||||
|
||||
*buf= '\0';
|
||||
return 0;
|
||||
@ -1187,8 +1173,6 @@ void _db_enter_(const char *_func_, const char *_file_,
|
||||
if (!TRACING) break;
|
||||
/* fall through */
|
||||
case DO_TRACE:
|
||||
if ((cs->stack->flags & SANITY_CHECK_ON) && _sanity(_file_,_line_))
|
||||
cs->stack->flags &= ~SANITY_CHECK_ON;
|
||||
if (TRACING)
|
||||
{
|
||||
if (!cs->locked)
|
||||
@ -1247,9 +1231,6 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
|
||||
#endif
|
||||
if (DoTrace(cs) & DO_TRACE)
|
||||
{
|
||||
if ((cs->stack->flags & SANITY_CHECK_ON) &&
|
||||
_sanity(_stack_frame_->file,_line_))
|
||||
cs->stack->flags &= ~SANITY_CHECK_ON;
|
||||
if (TRACING)
|
||||
{
|
||||
if (!cs->locked)
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -387,15 +387,15 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
|
||||
struct errors *tmp_error, *next_error;
|
||||
uint count, i;
|
||||
|
||||
my_free((uchar*) default_language, MYF(0));
|
||||
my_free((void*) default_language);
|
||||
|
||||
for (tmp_lang= lang_head; tmp_lang; tmp_lang= next_language)
|
||||
{
|
||||
next_language= tmp_lang->next_lang;
|
||||
my_free(tmp_lang->lang_short_name, MYF(0));
|
||||
my_free(tmp_lang->lang_long_name, MYF(0));
|
||||
my_free(tmp_lang->charset, MYF(0));
|
||||
my_free((uchar*) tmp_lang, MYF(0));
|
||||
my_free(tmp_lang->lang_short_name);
|
||||
my_free(tmp_lang->lang_long_name);
|
||||
my_free(tmp_lang->charset);
|
||||
my_free(tmp_lang);
|
||||
}
|
||||
|
||||
for (tmp_error= error_head; tmp_error; tmp_error= next_error)
|
||||
@ -406,17 +406,17 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
|
||||
{
|
||||
struct message *tmp;
|
||||
tmp= dynamic_element(&tmp_error->msg, i, struct message*);
|
||||
my_free((uchar*) tmp->lang_short_name, MYF(0));
|
||||
my_free((uchar*) tmp->text, MYF(0));
|
||||
my_free(tmp->lang_short_name);
|
||||
my_free(tmp->text);
|
||||
}
|
||||
|
||||
delete_dynamic(&tmp_error->msg);
|
||||
if (tmp_error->sql_code1[0])
|
||||
my_free((uchar*) tmp_error->sql_code1, MYF(0));
|
||||
my_free((void*) tmp_error->sql_code1);
|
||||
if (tmp_error->sql_code2[0])
|
||||
my_free((uchar*) tmp_error->sql_code2, MYF(0));
|
||||
my_free((uchar*) tmp_error->er_name, MYF(0));
|
||||
my_free((uchar*) tmp_error, MYF(0));
|
||||
my_free((void*) tmp_error->sql_code2);
|
||||
my_free((void*) tmp_error->er_name);
|
||||
my_free(tmp_error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -559,7 +559,7 @@ static uint parse_error_offset(char *str)
|
||||
|
||||
end= 0;
|
||||
ioffset= (uint) my_strtoll10(soffset, &end, &error);
|
||||
my_free((uchar*) soffset, MYF(0));
|
||||
my_free(soffset);
|
||||
DBUG_RETURN(ioffset);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -262,7 +262,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
|
||||
if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
|
||||
MYF(MY_WME))))
|
||||
{
|
||||
my_free((uchar*) pa->typelib.type_names,MYF(0));
|
||||
my_free(pa->typelib.type_names);
|
||||
DBUG_RETURN (-1);
|
||||
}
|
||||
pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
|
||||
@ -324,9 +324,9 @@ static void free_pointer_array(reg1 POINTER_ARRAY *pa)
|
||||
if (pa->typelib.count)
|
||||
{
|
||||
pa->typelib.count=0;
|
||||
my_free((uchar*) pa->typelib.type_names,MYF(0));
|
||||
my_free(pa->typelib.type_names);
|
||||
pa->typelib.type_names=0;
|
||||
my_free((uchar*) pa->str,MYF(0));
|
||||
my_free(pa->str);
|
||||
}
|
||||
return;
|
||||
} /* free_pointer_array */
|
||||
@ -441,7 +441,7 @@ static REPLACE *init_replace(char * *from, char * *to,uint count,
|
||||
if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME))))
|
||||
{
|
||||
free_sets(&sets);
|
||||
my_free((uchar*) found_set,MYF(0));
|
||||
my_free(found_set);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@ -663,9 +663,9 @@ static REPLACE *init_replace(char * *from, char * *to,uint count,
|
||||
replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1));
|
||||
}
|
||||
}
|
||||
my_free((uchar*) follow,MYF(0));
|
||||
my_free(follow);
|
||||
free_sets(&sets);
|
||||
my_free((uchar*) found_set,MYF(0));
|
||||
my_free(found_set);
|
||||
DBUG_PRINT("exit",("Replace table has %d states",sets.count));
|
||||
DBUG_RETURN(replace);
|
||||
}
|
||||
@ -681,7 +681,7 @@ static int init_sets(REP_SETS *sets,uint states)
|
||||
if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits*
|
||||
SET_MALLOC_HUNC,MYF(MY_WME))))
|
||||
{
|
||||
my_free((uchar*) sets->set,MYF(0));
|
||||
my_free(sets->set);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -742,8 +742,8 @@ static void free_last_set(REP_SETS *sets)
|
||||
|
||||
static void free_sets(REP_SETS *sets)
|
||||
{
|
||||
my_free((uchar*)sets->set_buffer,MYF(0));
|
||||
my_free((uchar*)sets->bit_buffer,MYF(0));
|
||||
my_free(sets->set_buffer);
|
||||
my_free(sets->bit_buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -950,8 +950,8 @@ static void reset_buffer()
|
||||
|
||||
static void free_buffer()
|
||||
{
|
||||
my_free(buffer,MYF(MY_WME));
|
||||
my_free(out_buff,MYF(MY_WME));
|
||||
my_free(buffer);
|
||||
my_free(out_buff);
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,14 +64,14 @@ typedef struct st_hash {
|
||||
typedef uint HASH_SEARCH_STATE;
|
||||
|
||||
#define my_hash_init(A,B,C,D,E,F,G,H) \
|
||||
_my_hash_init(A,0,B,C,D,E,F,G,H CALLER_INFO)
|
||||
_my_hash_init(A,0,B,C,D,E,F,G,H)
|
||||
#define my_hash_init2(A,B,C,D,E,F,G,H,I) \
|
||||
_my_hash_init(A,B,C,D,E,F,G,H,I CALLER_INFO)
|
||||
_my_hash_init(A,B,C,D,E,F,G,H,I)
|
||||
my_bool _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
|
||||
ulong default_array_elements, size_t key_offset,
|
||||
size_t key_length, my_hash_get_key get_key,
|
||||
void (*free_element)(void*),
|
||||
uint flags CALLER_INFO_PROTO);
|
||||
uint flags);
|
||||
void my_hash_free(HASH *tree);
|
||||
void my_hash_reset(HASH *hash);
|
||||
uchar *my_hash_element(HASH *hash, ulong idx);
|
||||
@ -100,7 +100,7 @@ my_bool my_hash_check(HASH *hash); /* Only in debug library */
|
||||
#define my_hash_clear(H) bzero((char*) (H), sizeof(*(H)))
|
||||
#define my_hash_inited(H) ((H)->blength != 0)
|
||||
#define my_hash_init_opt(A,B,C,D,E,F,G,H) \
|
||||
(!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))
|
||||
(!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G,H))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ uint lf_alloc_pool_count(LF_ALLOCATOR *allocator);
|
||||
#define lf_alloc_get_pins(A) lf_pinbox_get_pins(&(A)->pinbox)
|
||||
#define _lf_alloc_put_pins(PINS) _lf_pinbox_put_pins(PINS)
|
||||
#define lf_alloc_put_pins(PINS) lf_pinbox_put_pins(PINS)
|
||||
#define lf_alloc_direct_free(ALLOC, ADDR) my_free((uchar*)(ADDR), MYF(0))
|
||||
#define lf_alloc_direct_free(ALLOC, ADDR) my_free((ADDR))
|
||||
|
||||
lock_wrap(lf_alloc_new, void *,
|
||||
(LF_PINS *pins),
|
||||
|
@ -889,11 +889,8 @@ typedef SOCKET_SIZE_TYPE size_socket;
|
||||
How much overhead does malloc have. The code often allocates
|
||||
something like 1024-MALLOC_OVERHEAD bytes
|
||||
*/
|
||||
#ifdef SAFEMALLOC
|
||||
#define MALLOC_OVERHEAD (8+24+4)
|
||||
#else
|
||||
#define MALLOC_OVERHEAD 8
|
||||
#endif
|
||||
|
||||
/* get memory in huncs */
|
||||
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
|
||||
/* Typical record cash */
|
||||
@ -1712,11 +1709,6 @@ inline void operator delete[](void*, void*) { /* Do nothing */ }
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define x_free(A) \
|
||||
do { my_free((uchar*)(A), MYF(MY_WME|MY_FAE|MY_ALLOW_ZERO_PTR)); } while (0)
|
||||
#define safeFree(X) \
|
||||
do { if (X) { my_free((uchar*)(X), MYF(0)); (X) = NULL; } } while (0)
|
||||
|
||||
/*
|
||||
Only Linux is known to need an explicit sync of the directory to make sure a
|
||||
file creation/deletion/renaming in(from,to) this directory durable.
|
||||
|
@ -37,7 +37,7 @@ extern int list_walk(LIST *,list_walk_action action,unsigned char * argument);
|
||||
|
||||
#define list_rest(a) ((a)->next)
|
||||
#define list_push(a,b) (a)=list_cons((b),(a))
|
||||
#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((unsigned char *) old,MYF(MY_FAE)); }
|
||||
#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old); my_free(old); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ extern size_t my_quick_read(File Filedes,uchar *Buffer,size_t Count,
|
||||
myf myFlags);
|
||||
extern size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count);
|
||||
|
||||
#if !defined(SAFEMALLOC) && defined(USE_HALLOC)
|
||||
#if defined(USE_HALLOC)
|
||||
#define my_malloc(a,b) halloc(a,1)
|
||||
#define my_no_flags_free(a) hfree(a)
|
||||
#endif
|
||||
|
@ -158,46 +158,15 @@ extern int NEAR my_errno; /* Last error in mysys */
|
||||
#define GETDATE_FIXEDLENGTH 16
|
||||
|
||||
/* defines when allocating data */
|
||||
#ifdef SAFEMALLOC
|
||||
#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG )
|
||||
#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG )
|
||||
#define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG )
|
||||
#define my_checkmalloc() _sanity( __FILE__, __LINE__ )
|
||||
#define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG)
|
||||
#define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C)
|
||||
#define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C)
|
||||
#define my_strndup(A,B,C) _my_strndup((A),(B),__FILE__,__LINE__,C)
|
||||
#define TRASH(A,B) do { bfill(A, B, 0x8F); MEM_UNDEFINED(A, B); } while (0)
|
||||
#define QUICK_SAFEMALLOC sf_malloc_quick=1
|
||||
#define NORMAL_SAFEMALLOC sf_malloc_quick=0
|
||||
extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
|
||||
extern ulonglong sf_malloc_mem_limit;
|
||||
|
||||
#define CALLER_INFO_PROTO , const char *sFile, uint uLine
|
||||
#define CALLER_INFO , __FILE__, __LINE__
|
||||
#define ORIG_CALLER_INFO , sFile, uLine
|
||||
#else
|
||||
#define my_checkmalloc()
|
||||
#undef TERMINATE
|
||||
#define TERMINATE(A,B) {}
|
||||
#define QUICK_SAFEMALLOC
|
||||
#define NORMAL_SAFEMALLOC
|
||||
extern void *my_malloc(size_t Size,myf MyFlags);
|
||||
#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
|
||||
extern void *my_multi_malloc(myf MyFlags, ...);
|
||||
extern void *my_realloc(void *oldpoint, size_t Size, myf MyFlags);
|
||||
extern void my_no_flags_free(void *ptr);
|
||||
extern void my_free(void *ptr);
|
||||
extern void *my_memdup(const void *from,size_t length,myf MyFlags);
|
||||
extern char *my_strdup(const char *from,myf MyFlags);
|
||||
extern char *my_strndup(const char *from, size_t length,
|
||||
myf MyFlags);
|
||||
/* we do use FG (as a no-op) in below so that a typo on FG is caught */
|
||||
#define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR))
|
||||
#define CALLER_INFO_PROTO /* nothing */
|
||||
#define CALLER_INFO /* nothing */
|
||||
#define ORIG_CALLER_INFO /* nothing */
|
||||
#define TRASH(A,B) do{MEM_CHECK_ADDRESSABLE(A,B);MEM_UNDEFINED(A,B);} while (0)
|
||||
#endif
|
||||
|
||||
#if defined(ENABLED_DEBUG_SYNC)
|
||||
extern void (*debug_sync_C_callback_ptr)(const char *, size_t);
|
||||
#define DEBUG_SYNC_C(_sync_point_name_) do { \
|
||||
@ -211,11 +180,11 @@ extern void (*debug_sync_C_callback_ptr)(const char *, size_t);
|
||||
#ifdef HAVE_LARGE_PAGES
|
||||
extern uint my_get_large_page_size(void);
|
||||
extern uchar * my_large_malloc(size_t size, myf my_flags);
|
||||
extern void my_large_free(uchar * ptr, myf my_flags);
|
||||
extern void my_large_free(uchar *ptr);
|
||||
#else
|
||||
#define my_get_large_page_size() (0)
|
||||
#define my_large_malloc(A,B) my_malloc_lock((A),(B))
|
||||
#define my_large_free(A,B) my_free_lock((A),(B))
|
||||
#define my_large_free(A) my_free_lock((A))
|
||||
#endif /* HAVE_LARGE_PAGES */
|
||||
|
||||
#ifdef HAVE_ALLOCA
|
||||
@ -233,7 +202,7 @@ extern void my_large_free(uchar * ptr, myf my_flags);
|
||||
#define my_afree(PTR) {}
|
||||
#else
|
||||
#define my_alloca(SZ) my_malloc(SZ,MYF(0))
|
||||
#define my_afree(PTR) my_free(PTR,MYF(MY_WME))
|
||||
#define my_afree(PTR) my_free(PTR)
|
||||
#endif /* HAVE_ALLOCA */
|
||||
|
||||
#ifndef errno /* did we already get it? */
|
||||
@ -642,20 +611,6 @@ extern size_t my_fwrite(FILE *stream,const uchar *Buffer,size_t Count,
|
||||
myf MyFlags);
|
||||
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
|
||||
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
|
||||
extern void *_mymalloc(size_t uSize,const char *sFile,
|
||||
uint uLine, myf MyFlag);
|
||||
extern void *_myrealloc(void *pPtr,size_t uSize,const char *sFile,
|
||||
uint uLine, myf MyFlag);
|
||||
extern void * my_multi_malloc _VARARGS((myf MyFlags, ...));
|
||||
extern void _myfree(void *pPtr,const char *sFile,uint uLine, myf MyFlag);
|
||||
extern int _sanity(const char *sFile, uint uLine);
|
||||
extern void *_my_memdup(const void *from, size_t length,
|
||||
const char *sFile, uint uLine,myf MyFlag);
|
||||
extern char * _my_strdup(const char *from, const char *sFile, uint uLine,
|
||||
myf MyFlag);
|
||||
extern char *_my_strndup(const char *from, size_t length,
|
||||
const char *sFile, uint uLine,
|
||||
myf MyFlag);
|
||||
|
||||
/* implemented in my_memmem.c */
|
||||
extern void *my_memmem(const void *haystack, size_t haystacklen,
|
||||
@ -684,9 +639,6 @@ extern HANDLE my_get_osfhandle(File fd);
|
||||
extern void my_osmaperr(unsigned long last_error);
|
||||
#endif
|
||||
|
||||
#ifndef TERMINATE
|
||||
extern void TERMINATE(FILE *file, uint flag);
|
||||
#endif
|
||||
extern void init_glob_errs(void);
|
||||
extern const char** get_global_errmsgs();
|
||||
extern void wait_for_free_space(const char *filename, int errors);
|
||||
@ -835,18 +787,16 @@ extern my_bool real_open_cached_file(IO_CACHE *cache);
|
||||
extern void close_cached_file(IO_CACHE *cache);
|
||||
File create_temp_file(char *to, const char *dir, const char *pfx,
|
||||
int mode, myf MyFlags);
|
||||
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D CALLER_INFO)
|
||||
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D ORIG_CALLER_INFO)
|
||||
#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E CALLER_INFO)
|
||||
#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E ORIG_CALLER_INFO)
|
||||
extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array,uint element_size,
|
||||
void *init_buffer, uint init_alloc,
|
||||
uint alloc_increment
|
||||
CALLER_INFO_PROTO);
|
||||
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
|
||||
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
|
||||
#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
|
||||
#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
|
||||
extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
|
||||
void *init_buffer, uint init_alloc,
|
||||
uint alloc_increment);
|
||||
/* init_dynamic_array() function is deprecated */
|
||||
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
|
||||
uint init_alloc,uint alloc_increment
|
||||
CALLER_INFO_PROTO);
|
||||
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
|
||||
uint init_alloc, uint alloc_increment);
|
||||
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,uchar * element);
|
||||
extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern uchar *pop_dynamic(DYNAMIC_ARRAY*);
|
||||
@ -876,10 +826,10 @@ extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
|
||||
extern void dynstr_free(DYNAMIC_STRING *str);
|
||||
#ifdef HAVE_MLOCK
|
||||
extern void *my_malloc_lock(size_t length,myf flags);
|
||||
extern void my_free_lock(void *ptr,myf flags);
|
||||
extern void my_free_lock(void *ptr);
|
||||
#else
|
||||
#define my_malloc_lock(A,B) my_malloc((A),(B))
|
||||
#define my_free_lock(A,B) my_free((A),(B))
|
||||
#define my_free_lock(A) my_free((A))
|
||||
#endif
|
||||
#define alloc_root_inited(A) ((A)->min_malloc != 0)
|
||||
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 \
|
||||
|
@ -49,7 +49,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
|
||||
ctype-uca.lo xml.lo my_strtoll10.lo str_alloc.lo dtoa.lo
|
||||
|
||||
mystringsextra= strto.c
|
||||
dbugobjects = dbug.lo # IT IS IN SAFEMALLOC.C sanity.lo
|
||||
dbugobjects = dbug.lo
|
||||
mysysheaders = mysys_priv.h my_static.h
|
||||
vioheaders = vio_priv.h
|
||||
mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
|
||||
@ -57,7 +57,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
|
||||
my_file.lo my_read.lo my_write.lo errors.lo \
|
||||
my_error.lo my_getwd.lo my_div.lo \
|
||||
mf_pack.lo my_mess.lo mf_dirname.lo mf_fn_ext.lo\
|
||||
mf_wcomp.lo typelib.lo safemalloc.lo my_alloc.lo \
|
||||
mf_wcomp.lo typelib.lo my_alloc.lo \
|
||||
mf_format.lo mf_path.lo mf_unixpath.lo my_fopen.lo \
|
||||
my_symlink.lo my_fstream.lo mf_arr_appstr.lo \
|
||||
mf_loadpath.lo my_pthread.lo my_thr_init.lo \
|
||||
|
@ -341,7 +341,7 @@ mysql_connect(MYSQL *mysql,const char *host,
|
||||
if (!(res=mysql_real_connect(mysql,host,user,passwd,NullS,0,NullS,0)))
|
||||
{
|
||||
if (mysql->free_me)
|
||||
my_free((uchar*) mysql,MYF(0));
|
||||
my_free(mysql);
|
||||
}
|
||||
mysql->reconnect= 1;
|
||||
DBUG_RETURN(res);
|
||||
@ -457,9 +457,9 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
||||
if (rc == 0)
|
||||
{
|
||||
/* Free old connect information */
|
||||
my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->user);
|
||||
my_free(mysql->passwd);
|
||||
my_free(mysql->db);
|
||||
|
||||
/* alloc new connect information */
|
||||
mysql->user= my_strdup(user,MYF(MY_WME));
|
||||
@ -604,7 +604,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename)
|
||||
err:
|
||||
/* free up memory allocated with _init, usually */
|
||||
(*options->local_infile_end)(li_ptr);
|
||||
my_free(buf, MYF(0));
|
||||
my_free(buf);
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
@ -715,7 +715,7 @@ static void default_local_infile_end(void *ptr)
|
||||
{
|
||||
if (data->fd >= 0)
|
||||
my_close(data->fd, MYF(MY_WME));
|
||||
my_free(ptr, MYF(MY_WME));
|
||||
my_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2206,7 +2206,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
|
||||
}
|
||||
result= execute(stmt, param_data, length);
|
||||
stmt->send_types_to_server=0;
|
||||
my_free(param_data, MYF(MY_WME));
|
||||
my_free(param_data);
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
DBUG_RETURN((int) execute(stmt,0,0));
|
||||
@ -4707,7 +4707,7 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
|
||||
}
|
||||
}
|
||||
|
||||
my_free((uchar*) stmt, MYF(MY_WME));
|
||||
my_free(stmt);
|
||||
|
||||
DBUG_RETURN(test(rc));
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data)
|
||||
strmake(net->last_error, ei->info, sizeof(net->last_error)-1);
|
||||
memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate));
|
||||
mysql->server_status= ei->server_status;
|
||||
my_free(data, MYF(0));
|
||||
my_free(data);
|
||||
}
|
||||
|
||||
static my_bool
|
||||
@ -207,7 +207,7 @@ static MYSQL_FIELD *emb_list_fields(MYSQL *mysql)
|
||||
res= ((THD*) mysql->thd)->cur_data;
|
||||
((THD*) mysql->thd)->cur_data= 0;
|
||||
mysql->field_alloc= res->alloc;
|
||||
my_free(res,MYF(0));
|
||||
my_free(res);
|
||||
mysql->status= MYSQL_STATUS_READY;
|
||||
return mysql->fields;
|
||||
}
|
||||
@ -236,7 +236,7 @@ static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
|
||||
stmt->fields= mysql->fields;
|
||||
stmt->mem_root= res->alloc;
|
||||
mysql->fields= NULL;
|
||||
my_free(res,MYF(0));
|
||||
my_free(res);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -293,7 +293,7 @@ static my_bool emb_read_query_result(MYSQL *mysql)
|
||||
thd->cur_data= res;
|
||||
}
|
||||
else
|
||||
my_free(res, MYF(0));
|
||||
my_free(res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -335,7 +335,7 @@ int emb_read_binary_rows(MYSQL_STMT *stmt)
|
||||
return 1;
|
||||
}
|
||||
stmt->result= *data;
|
||||
my_free((char *) data, MYF(0));
|
||||
my_free(data);
|
||||
set_stmt_errmsg(stmt, &stmt->mysql->net);
|
||||
return 0;
|
||||
}
|
||||
@ -590,7 +590,7 @@ int init_embedded_server(int argc, char **argv, char **groups)
|
||||
|
||||
void end_embedded_server()
|
||||
{
|
||||
my_free((char*) copy_arguments_ptr, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(copy_arguments_ptr);
|
||||
copy_arguments_ptr=0;
|
||||
clean_up(0);
|
||||
}
|
||||
|
@ -119,8 +119,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
(mysql->options.my_cnf_file ?
|
||||
mysql->options.my_cnf_file : "my"),
|
||||
mysql->options.my_cnf_group);
|
||||
my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.my_cnf_file);
|
||||
my_free(mysql->options.my_cnf_group);
|
||||
mysql->options.my_cnf_file=mysql->options.my_cnf_group=0;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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: $_";
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -1 +0,0 @@
|
||||
--loose-skip-safemalloc
|
@ -29,10 +29,10 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
|
||||
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
|
||||
my_lib.c my_lock.c my_lockmem.c my_malloc.c my_mess.c
|
||||
my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c
|
||||
my_quick.c my_read.c my_realloc.c my_redel.c my_rename.c my_seek.c my_sleep.c
|
||||
my_quick.c my_read.c my_redel.c my_rename.c my_seek.c my_sleep.c
|
||||
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c
|
||||
my_write.c ptr_cmp.c queues.c stacktrace.c
|
||||
rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
|
||||
rijndael.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
|
||||
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
|
||||
lf_alloc-pin.c lf_dynarray.c lf_hash.c
|
||||
my_atomic.c my_getncpus.c
|
||||
|
@ -29,9 +29,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
|
||||
mf_keycaches.c my_crc32.c \
|
||||
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
|
||||
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
|
||||
my_malloc.c my_realloc.c my_once.c mulalloc.c \
|
||||
my_alloc.c safemalloc.c my_new.cc \
|
||||
my_vle.c my_atomic.c lf_hash.c \
|
||||
my_malloc.c my_once.c mulalloc.c \
|
||||
my_alloc.c my_new.cc my_vle.c my_atomic.c lf_hash.c \
|
||||
lf_dynarray.c lf_alloc-pin.c \
|
||||
my_fopen.c my_fstream.c my_getsystime.c \
|
||||
my_error.c errors.c my_div.c my_mess.c \
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
|
||||
void *init_buffer, uint init_alloc,
|
||||
uint alloc_increment CALLER_INFO_PROTO)
|
||||
uint alloc_increment)
|
||||
{
|
||||
DBUG_ENTER("init_dynamic_array");
|
||||
if (!alloc_increment)
|
||||
@ -67,14 +67,13 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
|
||||
Since the dynamic array is usable even if allocation fails here malloc
|
||||
should not throw an error
|
||||
*/
|
||||
if (!(array->buffer= (uchar*) my_malloc_ci(element_size*init_alloc, MYF(0))))
|
||||
if (!(array->buffer= (uchar*) my_malloc(element_size*init_alloc, MYF(0))))
|
||||
array->max_element=0;
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
|
||||
uint init_alloc,
|
||||
uint alloc_increment CALLER_INFO_PROTO)
|
||||
uint init_alloc, uint alloc_increment)
|
||||
{
|
||||
/* placeholder to preserve ABI */
|
||||
return my_init_dynamic_array_ci(array, element_size, init_alloc,
|
||||
@ -306,7 +305,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array)
|
||||
else
|
||||
if (array->buffer)
|
||||
{
|
||||
my_free(array->buffer,MYF(MY_WME));
|
||||
my_free(array->buffer);
|
||||
array->buffer=0;
|
||||
array->elements=array->max_element=0;
|
||||
}
|
||||
|
@ -383,11 +383,11 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
|
||||
#endif
|
||||
}
|
||||
|
||||
my_free(buf, myflags);
|
||||
my_free(buf);
|
||||
return FALSE;
|
||||
|
||||
error:
|
||||
my_free(buf, myflags);
|
||||
my_free(buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -223,11 +223,11 @@ int modify_defaults_file(const char *file_location, const char *option,
|
||||
if (my_fclose(cnf_file, MYF(MY_WME)))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
my_free(file_buffer, MYF(0));
|
||||
my_free(file_buffer);
|
||||
DBUG_RETURN(0);
|
||||
|
||||
err:
|
||||
my_free(file_buffer, MYF(0));
|
||||
my_free(file_buffer);
|
||||
malloc_err:
|
||||
my_fclose(cnf_file, MYF(0));
|
||||
DBUG_RETURN(1); /* out of resources */
|
||||
|
@ -67,8 +67,6 @@ static my_hash_value_type calc_hash(const HASH *hash,
|
||||
@param[in] get_key get the key for the hash
|
||||
@param[in] free_element pointer to the function that
|
||||
does cleanup
|
||||
@param[in] CALLER_INFO_PROTO flag that define the behaviour
|
||||
of the hash
|
||||
@return inidicates success or failure of initialization
|
||||
@retval 0 success
|
||||
@retval 1 failure
|
||||
@ -77,7 +75,7 @@ my_bool
|
||||
_my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
|
||||
ulong size, size_t key_offset, size_t key_length,
|
||||
my_hash_get_key get_key,
|
||||
void (*free_element)(void*), uint flags CALLER_INFO_PROTO)
|
||||
void (*free_element)(void*), uint flags)
|
||||
{
|
||||
DBUG_ENTER("my_hash_init");
|
||||
DBUG_PRINT("enter",("hash: 0x%lx size: %u", (long) hash, (uint) size));
|
||||
|
@ -472,7 +472,7 @@ void lf_alloc_destroy(LF_ALLOCATOR *allocator)
|
||||
uchar *tmp= anext_node(node);
|
||||
if (allocator->destructor)
|
||||
allocator->destructor(node);
|
||||
my_free((void *)node, MYF(0));
|
||||
my_free(node);
|
||||
node= tmp;
|
||||
}
|
||||
lf_pinbox_destroy(&allocator->pinbox);
|
||||
|
@ -57,10 +57,10 @@ static void recursive_free(void **alloc, int level)
|
||||
int i;
|
||||
for (i= 0; i < LF_DYNARRAY_LEVEL_LENGTH; i++)
|
||||
recursive_free(alloc[i], level-1);
|
||||
my_free((void *)alloc, MYF(0));
|
||||
my_free(alloc);
|
||||
}
|
||||
else
|
||||
my_free(alloc[-1], MYF(0));
|
||||
my_free(alloc[-1]);
|
||||
}
|
||||
|
||||
void lf_dynarray_destroy(LF_DYNARRAY *array)
|
||||
@ -115,7 +115,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
|
||||
if (my_atomic_casptr(ptr_ptr, &ptr, alloc))
|
||||
ptr= alloc;
|
||||
else
|
||||
my_free(alloc, MYF(0));
|
||||
my_free(alloc);
|
||||
}
|
||||
ptr_ptr= ((void **)ptr) + idx / dynarray_idxes_in_prev_level[i];
|
||||
idx%= dynarray_idxes_in_prev_level[i];
|
||||
@ -139,7 +139,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
|
||||
if (my_atomic_casptr(ptr_ptr, &ptr, data))
|
||||
ptr= data;
|
||||
else
|
||||
my_free(alloc, MYF(0));
|
||||
my_free(alloc);
|
||||
}
|
||||
return ((uchar*)ptr) + array->size_of_element * idx;
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ void lf_hash_destroy(LF_HASH *hash)
|
||||
if (el->hashnr & 1)
|
||||
lf_alloc_direct_free(&hash->alloc, el); /* normal node */
|
||||
else
|
||||
my_free((void *)el, MYF(0)); /* dummy node */
|
||||
my_free(el); /* dummy node */
|
||||
el= (LF_SLIST *)next;
|
||||
}
|
||||
lf_alloc_destroy(&hash->alloc);
|
||||
@ -489,7 +489,7 @@ static int initialize_bucket(LF_HASH *hash, LF_SLIST * volatile *node,
|
||||
dummy->keylen= 0;
|
||||
if ((cur= linsert(el, hash->charset, dummy, pins, LF_HASH_UNIQUE)))
|
||||
{
|
||||
my_free((void *)dummy, MYF(0));
|
||||
my_free(dummy);
|
||||
dummy= cur;
|
||||
}
|
||||
my_atomic_casptr((void **)node, (void **)&tmp, dummy);
|
||||
|
@ -61,8 +61,8 @@ void list_free(LIST *root, uint free_data)
|
||||
{
|
||||
next=root->next;
|
||||
if (free_data)
|
||||
my_free((uchar*) root->data,MYF(0));
|
||||
my_free((uchar*) root,MYF(0));
|
||||
my_free(root->data);
|
||||
my_free(root);
|
||||
root=next;
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix,
|
||||
{
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
my_free(cache->dir, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(cache->dir);
|
||||
my_free(cache->prefix);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
@ -110,12 +110,12 @@ void close_cached_file(IO_CACHE *cache)
|
||||
if (cache->file_name)
|
||||
{
|
||||
(void) my_delete(cache->file_name,MYF(MY_WME | ME_NOINPUT));
|
||||
my_free(cache->file_name,MYF(0));
|
||||
my_free(cache->file_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
my_free(cache->dir,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(cache->dir);
|
||||
my_free(cache->prefix);
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -446,7 +446,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
|
||||
if ((keycache->block_root= (BLOCK_LINK*) my_malloc(length,
|
||||
MYF(0))))
|
||||
break;
|
||||
my_large_free(keycache->block_mem, MYF(0));
|
||||
my_large_free(keycache->block_mem);
|
||||
keycache->block_mem= 0;
|
||||
}
|
||||
if (blocks < 8)
|
||||
@ -521,12 +521,12 @@ err:
|
||||
keycache->blocks= 0;
|
||||
if (keycache->block_mem)
|
||||
{
|
||||
my_large_free((uchar*) keycache->block_mem, MYF(0));
|
||||
my_large_free((uchar*) keycache->block_mem);
|
||||
keycache->block_mem= NULL;
|
||||
}
|
||||
if (keycache->block_root)
|
||||
{
|
||||
my_free((uchar*) keycache->block_root, MYF(0));
|
||||
my_free(keycache->block_root);
|
||||
keycache->block_root= NULL;
|
||||
}
|
||||
my_errno= error;
|
||||
@ -747,9 +747,9 @@ void end_key_cache(KEY_CACHE *keycache, my_bool cleanup)
|
||||
{
|
||||
if (keycache->block_mem)
|
||||
{
|
||||
my_large_free((uchar*) keycache->block_mem, MYF(0));
|
||||
my_large_free((uchar*) keycache->block_mem);
|
||||
keycache->block_mem= NULL;
|
||||
my_free((uchar*) keycache->block_root, MYF(0));
|
||||
my_free(keycache->block_root);
|
||||
keycache->block_root= NULL;
|
||||
}
|
||||
keycache->disk_blocks= -1;
|
||||
@ -4080,7 +4080,7 @@ restart:
|
||||
#endif
|
||||
err:
|
||||
if (cache != cache_buff)
|
||||
my_free((uchar*) cache, MYF(0));
|
||||
my_free(cache);
|
||||
if (last_errno)
|
||||
errno=last_errno; /* Return first error */
|
||||
DBUG_RETURN(last_errno != 0);
|
||||
|
@ -71,7 +71,7 @@ typedef struct st_safe_hash_with_default
|
||||
static void safe_hash_entry_free(SAFE_HASH_ENTRY *entry)
|
||||
{
|
||||
DBUG_ENTER("free_assign_entry");
|
||||
my_free((uchar*) entry, MYF(0));
|
||||
my_free(entry);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
|
||||
if (my_hash_insert(&hash->hash, (uchar*) entry))
|
||||
{
|
||||
/* This can only happen if hash got out of memory */
|
||||
my_free((char*) entry, MYF(0));
|
||||
my_free(entry);
|
||||
error= 1;
|
||||
goto end;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ void my_string_ptr_sort(uchar *base, uint items, size_t size)
|
||||
(ptr= (uchar**) my_malloc(items*sizeof(char*),MYF(0))))
|
||||
{
|
||||
radixsort_for_str_ptr((uchar**) base,items,size,ptr);
|
||||
my_free((uchar*) ptr,MYF(0));
|
||||
my_free(ptr);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -120,7 +120,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
||||
{
|
||||
/* remove block from the list and free it */
|
||||
*prev= mem->next;
|
||||
my_free(mem, MYF(0));
|
||||
my_free(mem);
|
||||
}
|
||||
else
|
||||
prev= &mem->next;
|
||||
@ -362,13 +362,13 @@ void free_root(MEM_ROOT *root, myf MyFlags)
|
||||
{
|
||||
old=next; next= next->next ;
|
||||
if (old != root->pre_alloc)
|
||||
my_free(old,MYF(0));
|
||||
my_free(old);
|
||||
}
|
||||
for (next=root->free ; next ;)
|
||||
{
|
||||
old=next; next= next->next;
|
||||
if (old != root->pre_alloc)
|
||||
my_free(old,MYF(0));
|
||||
my_free(old);
|
||||
}
|
||||
root->used=root->free=0;
|
||||
if (root->pre_alloc)
|
||||
|
@ -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;
|
||||
|
@ -51,7 +51,7 @@ my_bool my_compress(uchar *packet, size_t *len, size_t *complen)
|
||||
if (!compbuf)
|
||||
DBUG_RETURN(*complen ? 0 : 1);
|
||||
memcpy(packet,compbuf,*len);
|
||||
my_free(compbuf,MYF(MY_WME));
|
||||
my_free(compbuf);
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
@ -73,14 +73,14 @@ uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen)
|
||||
|
||||
if (res != Z_OK)
|
||||
{
|
||||
my_free(compbuf, MYF(MY_WME));
|
||||
my_free(compbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*complen >= *len)
|
||||
{
|
||||
*complen= 0;
|
||||
my_free(compbuf, MYF(MY_WME));
|
||||
my_free(compbuf);
|
||||
DBUG_PRINT("note",("Packet got longer on compression; Not compressed"));
|
||||
return 0;
|
||||
}
|
||||
@ -125,11 +125,11 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen)
|
||||
if (error != Z_OK)
|
||||
{ /* Probably wrong packet */
|
||||
DBUG_PRINT("error",("Can't uncompress packet, error: %d",error));
|
||||
my_free(compbuf, MYF(MY_WME));
|
||||
my_free(compbuf);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
memcpy(packet, compbuf, *complen);
|
||||
my_free(compbuf, MYF(MY_WME));
|
||||
my_free(compbuf);
|
||||
}
|
||||
else
|
||||
*complen= len;
|
||||
@ -250,7 +250,7 @@ int unpackfrm(uchar **unpack_data, size_t *unpack_len,
|
||||
|
||||
if (my_uncompress(data, complen, &orglen))
|
||||
{
|
||||
my_free(data, MYF(0));
|
||||
my_free(data);
|
||||
DBUG_RETURN(3);
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ int my_error_register(const char** (*get_errmsgs) (), int first, int last)
|
||||
/* Error numbers must be unique. No overlapping is allowed. */
|
||||
if (*search_meh_pp && ((*search_meh_pp)->meh_first <= last))
|
||||
{
|
||||
my_free((uchar*)meh_p, MYF(0));
|
||||
my_free(meh_p);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ const char **my_error_unregister(int first, int last)
|
||||
|
||||
/* Save the return value and free the header. */
|
||||
errmsgs= meh_p->get_errmsgs();
|
||||
my_free((uchar*) meh_p, MYF(0));
|
||||
my_free(meh_p);
|
||||
|
||||
return errmsgs;
|
||||
}
|
||||
@ -282,7 +282,7 @@ void my_error_unregister_all(void)
|
||||
/* We need this ptr, but we're about to free its container, so save it. */
|
||||
saved_next= cursor->meh_next;
|
||||
|
||||
my_free((uchar*) cursor, MYF(0));
|
||||
my_free(cursor);
|
||||
}
|
||||
my_errmsgs_globerrs.meh_next= NULL; /* Freed in first iteration above. */
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -596,8 +596,7 @@ static int setval(const struct my_option *opts, void *value, char *argument,
|
||||
case GET_STR_ALLOC:
|
||||
if (argument == enabled_my_option)
|
||||
break; /* string options don't use this default of "1" */
|
||||
if ((*((char**) value)))
|
||||
my_free((*(char**) value), MYF(MY_WME | MY_FAE));
|
||||
my_free(*((char**) value));
|
||||
if (!(*((char**) value)= my_strdup(argument, MYF(MY_WME))))
|
||||
{
|
||||
res= EXIT_OUT_OF_MEMORY;
|
||||
@ -1054,8 +1053,9 @@ static void init_one_value(const struct my_option *option, void *variable,
|
||||
*/
|
||||
if ((char*) (intptr) value)
|
||||
{
|
||||
my_free((*(char**) variable), MYF(MY_ALLOW_ZERO_PTR));
|
||||
*((char**) variable)= my_strdup((char*) (intptr) value, MYF(MY_WME));
|
||||
char **pstr= (char **) variable;
|
||||
my_free(*pstr);
|
||||
*pstr= my_strdup((char*) (intptr) value, MYF(MY_WME));
|
||||
}
|
||||
break;
|
||||
default: /* dummy default to avoid compiler warnings */
|
||||
@ -1080,7 +1080,7 @@ static void fini_one_value(const struct my_option *option, void *variable,
|
||||
DBUG_ENTER("fini_one_value");
|
||||
switch ((option->var_type & GET_TYPE_MASK)) {
|
||||
case GET_STR_ALLOC:
|
||||
my_free((*(char**) variable), MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(*((char**) variable));
|
||||
*((char**) variable)= NULL;
|
||||
break;
|
||||
default: /* dummy default to avoid compiler warnings */
|
||||
|
@ -141,6 +141,7 @@ my_bool my_init(void)
|
||||
{
|
||||
if (my_init_done)
|
||||
return 0;
|
||||
|
||||
my_init_done= 1;
|
||||
|
||||
if (my_basic_init())
|
||||
@ -241,9 +242,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
|
||||
#if defined(__NETWARE__) && !defined(__WIN__)
|
||||
fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC);
|
||||
#endif
|
||||
#if defined(SAFEMALLOC)
|
||||
TERMINATE(stderr, (infoflag & MY_GIVE_INFO) != 0);
|
||||
#elif defined(__WIN__) && defined(_MSC_VER)
|
||||
#if defined(__WIN__) && defined(_MSC_VER)
|
||||
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
|
||||
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
|
||||
@ -254,10 +253,6 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
|
||||
_CrtDumpMemoryLeaks();
|
||||
#endif
|
||||
}
|
||||
else if (infoflag & MY_CHECK_ERROR)
|
||||
{
|
||||
TERMINATE(stderr, 0); /* Print memory leaks on screen */
|
||||
}
|
||||
|
||||
if (!(infoflag & MY_DONT_FREE_DBUG))
|
||||
{
|
||||
@ -280,6 +275,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
|
||||
if (have_tcpip)
|
||||
WSACleanup();
|
||||
#endif /* __WIN__ */
|
||||
|
||||
my_init_done=0;
|
||||
my_basic_init_done= 0;
|
||||
} /* my_end */
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
static uint my_get_large_page_size_int(void);
|
||||
static uchar* my_large_malloc_int(size_t size, myf my_flags);
|
||||
static my_bool my_large_free_int(uchar* ptr, myf my_flags);
|
||||
static my_bool my_large_free_int(uchar* ptr);
|
||||
|
||||
/* Gets the size of large pages from the OS */
|
||||
|
||||
@ -70,7 +70,7 @@ uchar* my_large_malloc(size_t size, myf my_flags)
|
||||
to my_free_lock() in case of failure
|
||||
*/
|
||||
|
||||
void my_large_free(uchar* ptr, myf my_flags __attribute__((unused)))
|
||||
void my_large_free(uchar* ptr)
|
||||
{
|
||||
DBUG_ENTER("my_large_free");
|
||||
|
||||
@ -79,9 +79,8 @@ void my_large_free(uchar* ptr, myf my_flags __attribute__((unused)))
|
||||
my_large_malloc_int(), i.e. my_malloc_lock() was used so we should free it
|
||||
with my_free_lock()
|
||||
*/
|
||||
if (!my_use_large_pages || !my_large_page_size ||
|
||||
!my_large_free_int(ptr, my_flags))
|
||||
my_free_lock(ptr, my_flags);
|
||||
if (!my_use_large_pages || !my_large_page_size || !my_large_free_int(ptr))
|
||||
my_free_lock(ptr);
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -157,7 +156,7 @@ uchar* my_large_malloc_int(size_t size, myf my_flags)
|
||||
|
||||
/* Linux-specific large pages deallocator */
|
||||
|
||||
my_bool my_large_free_int(uchar *ptr, myf my_flags __attribute__((unused)))
|
||||
my_bool my_large_free_int(uchar *ptr)
|
||||
{
|
||||
DBUG_ENTER("my_large_free_int");
|
||||
DBUG_RETURN(shmdt(ptr) == 0);
|
||||
|
@ -77,7 +77,7 @@ void my_dirend(MY_DIR *buffer)
|
||||
ALIGN_SIZE(sizeof(MY_DIR))));
|
||||
free_root((MEM_ROOT*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)) +
|
||||
ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))), MYF(0));
|
||||
my_free((uchar*) buffer,MYF(0));
|
||||
my_free(buffer);
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
} /* my_dirend */
|
||||
@ -131,7 +131,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
|
||||
if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
|
||||
ENTRIES_START_SIZE, ENTRIES_INCREMENT))
|
||||
{
|
||||
my_free((uchar*) buffer,MYF(0));
|
||||
my_free(buffer);
|
||||
goto error;
|
||||
}
|
||||
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
|
||||
@ -400,7 +400,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
|
||||
if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
|
||||
ENTRIES_START_SIZE, ENTRIES_INCREMENT))
|
||||
{
|
||||
my_free((uchar*) buffer,MYF(0));
|
||||
my_free(buffer);
|
||||
goto error;
|
||||
}
|
||||
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
|
||||
@ -547,7 +547,7 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
|
||||
DBUG_PRINT("error",("Got errno: %d from stat", errno));
|
||||
my_errno= errno;
|
||||
if (m_used) /* Free if new area */
|
||||
my_free((uchar*) stat_area,MYF(0));
|
||||
my_free(stat_area);
|
||||
|
||||
error:
|
||||
if (my_flags & (MY_FAE+MY_WME))
|
||||
|
@ -74,7 +74,7 @@ uchar *my_malloc_lock(uint size,myf MyFlags)
|
||||
}
|
||||
|
||||
|
||||
void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused)))
|
||||
void my_free_lock(uchar *ptr)
|
||||
{
|
||||
LIST *list;
|
||||
struct st_mem_list *element=0;
|
||||
@ -91,8 +91,7 @@ void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused)))
|
||||
}
|
||||
}
|
||||
mysql_mutex_unlock(&THR_LOCK_malloc);
|
||||
if (element)
|
||||
my_free((uchar*) element,MYF(0));
|
||||
my_free(element);
|
||||
free(ptr); /* Free even if not locked */
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -11,28 +11,31 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */
|
||||
#undef SAFEMALLOC
|
||||
#endif
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include "mysys_err.h"
|
||||
#include <m_string.h>
|
||||
|
||||
/* My memory allocator */
|
||||
/**
|
||||
Allocate a sized block of memory.
|
||||
|
||||
@param size The size of the memory block in bytes.
|
||||
@param flags Failure action modifiers (bitmasks).
|
||||
|
||||
@return A pointer to the allocated memory block, or NULL on failure.
|
||||
*/
|
||||
void *my_malloc(size_t size, myf my_flags)
|
||||
{
|
||||
void* point;
|
||||
DBUG_ENTER("my_malloc");
|
||||
DBUG_PRINT("my",("size: %lu my_flags: %d", (ulong) size, my_flags));
|
||||
|
||||
/* Safety */
|
||||
if (!size)
|
||||
size=1; /* Safety */
|
||||
size=1;
|
||||
|
||||
point= (char *) malloc(size);
|
||||
point= malloc(size);
|
||||
DBUG_EXECUTE_IF("simulate_out_of_memory",
|
||||
{
|
||||
free(point);
|
||||
@ -52,33 +55,87 @@ void *my_malloc(size_t size, myf my_flags)
|
||||
exit(1);
|
||||
}
|
||||
else if (my_flags & MY_ZEROFILL)
|
||||
bzero(point,size);
|
||||
DBUG_PRINT("exit",("ptr: 0x%lx", (long) point));
|
||||
DBUG_RETURN((void*) point);
|
||||
} /* my_malloc */
|
||||
bzero(point, size);
|
||||
DBUG_PRINT("exit",("ptr: %p", point));
|
||||
DBUG_RETURN(point);
|
||||
}
|
||||
|
||||
|
||||
/* Free memory allocated with my_malloc */
|
||||
/*ARGSUSED*/
|
||||
/**
|
||||
@brief wrapper around realloc()
|
||||
|
||||
void my_no_flags_free(void* ptr)
|
||||
@param oldpoint pointer to currently allocated area
|
||||
@param size new size requested, must be >0
|
||||
@param my_flags flags
|
||||
|
||||
@note if size==0 realloc() may return NULL; my_realloc() treats this as an
|
||||
error which is not the intention of realloc()
|
||||
*/
|
||||
void *my_realloc(void *oldpoint, size_t size, myf my_flags)
|
||||
{
|
||||
void *point;
|
||||
DBUG_ENTER("my_realloc");
|
||||
DBUG_PRINT("my",("ptr: %p size: %lu my_flags: %d", oldpoint,
|
||||
(ulong) size, my_flags));
|
||||
|
||||
DBUG_ASSERT(size > 0);
|
||||
if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
|
||||
DBUG_RETURN(my_malloc(size, my_flags));
|
||||
#ifdef USE_HALLOC
|
||||
if (!(point = malloc(size)))
|
||||
{
|
||||
if (my_flags & MY_FREE_ON_ERROR)
|
||||
my_free(oldpoint);
|
||||
if (my_flags & MY_HOLD_ON_ERROR)
|
||||
DBUG_RETURN(oldpoint);
|
||||
my_errno=errno;
|
||||
if (my_flags & MY_FAE+MY_WME)
|
||||
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(point,oldpoint,size);
|
||||
free(oldpoint);
|
||||
}
|
||||
#else
|
||||
if ((point= realloc(oldpoint, size)) == NULL)
|
||||
{
|
||||
if (my_flags & MY_FREE_ON_ERROR)
|
||||
my_free(oldpoint);
|
||||
if (my_flags & MY_HOLD_ON_ERROR)
|
||||
DBUG_RETURN(oldpoint);
|
||||
my_errno=errno;
|
||||
if (my_flags & (MY_FAE+MY_WME))
|
||||
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size);
|
||||
}
|
||||
#endif
|
||||
DBUG_PRINT("exit",("ptr: %p", point));
|
||||
DBUG_RETURN(point);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free memory allocated with my_malloc.
|
||||
|
||||
@remark Relies on free being able to handle a NULL argument.
|
||||
|
||||
@param ptr Pointer to the memory allocated by my_malloc.
|
||||
*/
|
||||
void my_free(void *ptr)
|
||||
{
|
||||
DBUG_ENTER("my_free");
|
||||
DBUG_PRINT("my",("ptr: 0x%lx", (long) ptr));
|
||||
if (ptr)
|
||||
free(ptr);
|
||||
DBUG_PRINT("my",("ptr: %p", ptr));
|
||||
free(ptr);
|
||||
DBUG_VOID_RETURN;
|
||||
} /* my_free */
|
||||
}
|
||||
|
||||
|
||||
/* malloc and copy */
|
||||
|
||||
void* my_memdup(const void *from, size_t length, myf my_flags)
|
||||
void *my_memdup(const void *from, size_t length, myf my_flags)
|
||||
{
|
||||
void *ptr;
|
||||
if ((ptr= my_malloc(length,my_flags)) != 0)
|
||||
memcpy(ptr, from, length);
|
||||
return(ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
@ -87,18 +144,19 @@ char *my_strdup(const char *from, myf my_flags)
|
||||
char *ptr;
|
||||
size_t length= strlen(from)+1;
|
||||
if ((ptr= (char*) my_malloc(length, my_flags)))
|
||||
memcpy((uchar*) ptr, (uchar*) from,(size_t) length);
|
||||
return(ptr);
|
||||
memcpy(ptr, from, length);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
char *my_strndup(const char *from, size_t length, myf my_flags)
|
||||
{
|
||||
char *ptr;
|
||||
if ((ptr= (char*) my_malloc(length+1,my_flags)) != 0)
|
||||
if ((ptr= (char*) my_malloc(length+1, my_flags)))
|
||||
{
|
||||
memcpy((uchar*) ptr, (uchar*) from, length);
|
||||
ptr[length]=0;
|
||||
memcpy(ptr, from, length);
|
||||
ptr[length]= 0;
|
||||
}
|
||||
return((char*) ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -1,75 +0,0 @@
|
||||
/* Copyright (C) 2000 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */
|
||||
#undef SAFEMALLOC
|
||||
#endif
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include "mysys_err.h"
|
||||
|
||||
/* My memory re allocator */
|
||||
|
||||
/**
|
||||
@brief wrapper around realloc()
|
||||
|
||||
@param oldpoint pointer to currently allocated area
|
||||
@param size new size requested, must be >0
|
||||
@param my_flags flags
|
||||
|
||||
@note if size==0 realloc() may return NULL; my_realloc() treats this as an
|
||||
error which is not the intention of realloc()
|
||||
*/
|
||||
void* my_realloc(void* oldpoint, size_t size, myf my_flags)
|
||||
{
|
||||
void *point;
|
||||
DBUG_ENTER("my_realloc");
|
||||
DBUG_PRINT("my",("ptr: 0x%lx size: %lu my_flags: %d", (long) oldpoint,
|
||||
(ulong) size, my_flags));
|
||||
|
||||
DBUG_ASSERT(size > 0);
|
||||
if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
|
||||
DBUG_RETURN(my_malloc(size,my_flags));
|
||||
#ifdef USE_HALLOC
|
||||
if (!(point = malloc(size)))
|
||||
{
|
||||
if (my_flags & MY_FREE_ON_ERROR)
|
||||
my_free(oldpoint,my_flags);
|
||||
if (my_flags & MY_HOLD_ON_ERROR)
|
||||
DBUG_RETURN(oldpoint);
|
||||
my_errno=errno;
|
||||
if (my_flags & MY_FAE+MY_WME)
|
||||
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(point,oldpoint,size);
|
||||
free(oldpoint);
|
||||
}
|
||||
#else
|
||||
if ((point= (uchar*) realloc(oldpoint,size)) == NULL)
|
||||
{
|
||||
if (my_flags & MY_FREE_ON_ERROR)
|
||||
my_free(oldpoint, my_flags);
|
||||
if (my_flags & MY_HOLD_ON_ERROR)
|
||||
DBUG_RETURN(oldpoint);
|
||||
my_errno=errno;
|
||||
if (my_flags & (MY_FAE+MY_WME))
|
||||
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size);
|
||||
}
|
||||
#endif
|
||||
DBUG_PRINT("exit",("ptr: 0x%lx", (long) point));
|
||||
DBUG_RETURN(point);
|
||||
} /* my_realloc */
|
@ -194,8 +194,8 @@ error:
|
||||
FreeSid(everyone_sid);
|
||||
if (htoken)
|
||||
CloseHandle(htoken);
|
||||
my_free((uchar*) sa, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((uchar*) dacl, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(sa);
|
||||
my_free(dacl);
|
||||
*psa= 0;
|
||||
return 1;
|
||||
}
|
||||
@ -215,8 +215,8 @@ void my_security_attr_free(SECURITY_ATTRIBUTES *sa)
|
||||
My_security_attr *attr= (My_security_attr*)
|
||||
(((char*)sa) + ALIGN_SIZE(sizeof(*sa)));
|
||||
FreeSid(attr->everyone_sid);
|
||||
my_free((uchar*) attr->dacl, MYF(0));
|
||||
my_free((uchar*) sa, MYF(0));
|
||||
my_free(attr->dacl);
|
||||
my_free(sa);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,11 +194,8 @@ int resize_queue(QUEUE *queue, uint max_elements)
|
||||
void delete_queue(QUEUE *queue)
|
||||
{
|
||||
DBUG_ENTER("delete_queue");
|
||||
if (queue->root)
|
||||
{
|
||||
my_free((uchar*) queue->root,MYF(0));
|
||||
queue->root=0;
|
||||
}
|
||||
my_free(queue->root);
|
||||
queue->root= NULL;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
@ -177,9 +177,6 @@ my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...)
|
||||
|
||||
void dynstr_free(DYNAMIC_STRING *str)
|
||||
{
|
||||
if (str->str)
|
||||
{
|
||||
my_free(str->str,MYF(MY_WME));
|
||||
str->str=0;
|
||||
}
|
||||
my_free(str->str);
|
||||
str->str= NULL;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -286,5 +286,5 @@ static int rnd(int max_value)
|
||||
|
||||
void free_record(void *record)
|
||||
{
|
||||
my_free(record,MYF(0));
|
||||
my_free(record);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -183,7 +183,7 @@ static void delete_tree_element(TREE *tree, TREE_ELEMENT *element)
|
||||
(*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
|
||||
delete_tree_element(tree,element->right);
|
||||
if (tree->with_delete)
|
||||
my_free((char*) element,MYF(0));
|
||||
my_free(element);
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,7 +326,7 @@ int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg)
|
||||
if (tree->free)
|
||||
(*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
|
||||
tree->allocated-= sizeof(TREE_ELEMENT) + tree->size_of_element + key_size;
|
||||
my_free((uchar*) element,MYF(0));
|
||||
my_free(element);
|
||||
tree->elements_in_tree--;
|
||||
return 0;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ static int daemon_example_plugin_deinit(void *p)
|
||||
my_write(con->heartbeat_file, (uchar*) buffer, strlen(buffer), MYF(0));
|
||||
my_close(con->heartbeat_file, MYF(0));
|
||||
|
||||
my_free((char *)con, MYF(0));
|
||||
my_free(con);
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ private:
|
||||
*/
|
||||
void free_block(Block *block)
|
||||
{
|
||||
my_free(block, MYF(0));
|
||||
my_free(block);
|
||||
--block_num;
|
||||
}
|
||||
|
||||
|
@ -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/;
|
||||
|
@ -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 \
|
||||
|
@ -688,8 +688,7 @@ err2:
|
||||
CloseHandle(handle_file_map);
|
||||
}
|
||||
err:
|
||||
if (tmp)
|
||||
my_free(tmp, MYF(0));
|
||||
my_free(tmp);
|
||||
if (error_allow)
|
||||
error_code = GetLastError();
|
||||
if (event_connect_request)
|
||||
@ -802,7 +801,7 @@ void free_rows(MYSQL_DATA *cur)
|
||||
if (cur)
|
||||
{
|
||||
free_root(&cur->alloc,MYF(0));
|
||||
my_free((uchar*) cur,MYF(0));
|
||||
my_free(cur);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1127,9 +1126,8 @@ mysql_free_result(MYSQL_RES *result)
|
||||
free_rows(result->data);
|
||||
if (result->fields)
|
||||
free_root(&result->field_alloc,MYF(0));
|
||||
if (result->row)
|
||||
my_free((uchar*) result->row,MYF(0));
|
||||
my_free((uchar*) result,MYF(0));
|
||||
my_free(result->row);
|
||||
my_free(result);
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -1167,13 +1165,13 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
|
||||
{
|
||||
options->init_commands= (DYNAMIC_ARRAY*)my_malloc(sizeof(DYNAMIC_ARRAY),
|
||||
MYF(MY_WME));
|
||||
init_dynamic_array(options->init_commands,sizeof(char*),0,5 CALLER_INFO);
|
||||
init_dynamic_array(options->init_commands,sizeof(char*),0,5);
|
||||
}
|
||||
|
||||
if (!(tmp= my_strdup(cmd,MYF(MY_WME))) ||
|
||||
insert_dynamic(options->init_commands, (uchar*)&tmp))
|
||||
{
|
||||
my_free(tmp, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(tmp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1221,7 +1219,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
|
||||
case 2: /* socket */
|
||||
if (opt_arg)
|
||||
{
|
||||
my_free(options->unix_socket,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->unix_socket);
|
||||
options->unix_socket=my_strdup(opt_arg,MYF(MY_WME));
|
||||
}
|
||||
break;
|
||||
@ -1232,7 +1230,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
|
||||
case 4: /* password */
|
||||
if (opt_arg)
|
||||
{
|
||||
my_free(options->password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->password);
|
||||
options->password=my_strdup(opt_arg,MYF(MY_WME));
|
||||
}
|
||||
break;
|
||||
@ -1246,7 +1244,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
|
||||
case 7: /* user */
|
||||
if (opt_arg)
|
||||
{
|
||||
my_free(options->user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->user);
|
||||
options->user=my_strdup(opt_arg,MYF(MY_WME));
|
||||
}
|
||||
break;
|
||||
@ -1256,14 +1254,14 @@ void mysql_read_default_options(struct st_mysql_options *options,
|
||||
case 9: /* host */
|
||||
if (opt_arg)
|
||||
{
|
||||
my_free(options->host,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->host);
|
||||
options->host=my_strdup(opt_arg,MYF(MY_WME));
|
||||
}
|
||||
break;
|
||||
case 10: /* database */
|
||||
if (opt_arg)
|
||||
{
|
||||
my_free(options->db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->db);
|
||||
options->db=my_strdup(opt_arg,MYF(MY_WME));
|
||||
}
|
||||
break;
|
||||
@ -1277,23 +1275,23 @@ void mysql_read_default_options(struct st_mysql_options *options,
|
||||
break;
|
||||
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
||||
case 13: /* ssl_key */
|
||||
my_free(options->ssl_key, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->ssl_key);
|
||||
options->ssl_key = my_strdup(opt_arg, MYF(MY_WME));
|
||||
break;
|
||||
case 14: /* ssl_cert */
|
||||
my_free(options->ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->ssl_cert);
|
||||
options->ssl_cert = my_strdup(opt_arg, MYF(MY_WME));
|
||||
break;
|
||||
case 15: /* ssl_ca */
|
||||
my_free(options->ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->ssl_ca);
|
||||
options->ssl_ca = my_strdup(opt_arg, MYF(MY_WME));
|
||||
break;
|
||||
case 16: /* ssl_capath */
|
||||
my_free(options->ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->ssl_capath);
|
||||
options->ssl_capath = my_strdup(opt_arg, MYF(MY_WME));
|
||||
break;
|
||||
case 23: /* ssl_cipher */
|
||||
my_free(options->ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->ssl_cipher);
|
||||
options->ssl_cipher= my_strdup(opt_arg, MYF(MY_WME));
|
||||
break;
|
||||
#else
|
||||
@ -1305,11 +1303,11 @@ void mysql_read_default_options(struct st_mysql_options *options,
|
||||
break;
|
||||
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
|
||||
case 17: /* charset-lib */
|
||||
my_free(options->charset_dir,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->charset_dir);
|
||||
options->charset_dir = my_strdup(opt_arg, MYF(MY_WME));
|
||||
break;
|
||||
case 18:
|
||||
my_free(options->charset_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->charset_name);
|
||||
options->charset_name = my_strdup(opt_arg, MYF(MY_WME));
|
||||
break;
|
||||
case 19: /* Interactive-timeout */
|
||||
@ -1339,7 +1337,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
|
||||
case 26: /* shared_memory_base_name */
|
||||
#ifdef HAVE_SMEM
|
||||
if (options->shared_memory_base_name != def_shared_memory_base_name)
|
||||
my_free(options->shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(options->shared_memory_base_name);
|
||||
options->shared_memory_base_name=my_strdup(opt_arg,MYF(MY_WME));
|
||||
#endif
|
||||
break;
|
||||
@ -1760,14 +1758,14 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
|
||||
struct st_VioSSLFd *ssl_fd= (struct st_VioSSLFd*) mysql->connector_fd;
|
||||
DBUG_ENTER("mysql_ssl_free");
|
||||
|
||||
my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.ssl_key);
|
||||
my_free(mysql->options.ssl_cert);
|
||||
my_free(mysql->options.ssl_ca);
|
||||
my_free(mysql->options.ssl_capath);
|
||||
my_free(mysql->options.ssl_cipher);
|
||||
if (ssl_fd)
|
||||
SSL_CTX_free(ssl_fd->ssl_context);
|
||||
my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->connector_fd);
|
||||
mysql->options.ssl_key = 0;
|
||||
mysql->options.ssl_cert = 0;
|
||||
mysql->options.ssl_ca = 0;
|
||||
@ -2271,8 +2269,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
|
||||
(mysql->options.my_cnf_file ?
|
||||
mysql->options.my_cnf_file : "my"),
|
||||
mysql->options.my_cnf_group);
|
||||
my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.my_cnf_file);
|
||||
my_free(mysql->options.my_cnf_group);
|
||||
mysql->options.my_cnf_file=mysql->options.my_cnf_group=0;
|
||||
}
|
||||
|
||||
@ -3014,7 +3012,7 @@ mysql_select_db(MYSQL *mysql, const char *db)
|
||||
if ((error=simple_command(mysql,COM_INIT_DB, (const uchar*) db,
|
||||
(ulong) strlen(db),0)))
|
||||
DBUG_RETURN(error);
|
||||
my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->db);
|
||||
mysql->db=my_strdup(db,MYF(MY_WME));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
@ -3029,32 +3027,32 @@ static void mysql_close_free_options(MYSQL *mysql)
|
||||
{
|
||||
DBUG_ENTER("mysql_close_free_options");
|
||||
|
||||
my_free(mysql->options.user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.host,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.password,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.unix_socket,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.client_ip,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.user);
|
||||
my_free(mysql->options.host);
|
||||
my_free(mysql->options.password);
|
||||
my_free(mysql->options.unix_socket);
|
||||
my_free(mysql->options.db);
|
||||
my_free(mysql->options.my_cnf_file);
|
||||
my_free(mysql->options.my_cnf_group);
|
||||
my_free(mysql->options.charset_dir);
|
||||
my_free(mysql->options.charset_name);
|
||||
my_free(mysql->options.client_ip);
|
||||
if (mysql->options.init_commands)
|
||||
{
|
||||
DYNAMIC_ARRAY *init_commands= mysql->options.init_commands;
|
||||
char **ptr= (char**)init_commands->buffer;
|
||||
char **end= ptr + init_commands->elements;
|
||||
for (; ptr<end; ptr++)
|
||||
my_free(*ptr,MYF(MY_WME));
|
||||
my_free(*ptr);
|
||||
delete_dynamic(init_commands);
|
||||
my_free((char*)init_commands,MYF(MY_WME));
|
||||
my_free(init_commands);
|
||||
}
|
||||
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
||||
mysql_ssl_free(mysql);
|
||||
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
|
||||
#ifdef HAVE_SMEM
|
||||
if (mysql->options.shared_memory_base_name != def_shared_memory_base_name)
|
||||
my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.shared_memory_base_name);
|
||||
#endif /* HAVE_SMEM */
|
||||
bzero((char*) &mysql->options,sizeof(mysql->options));
|
||||
DBUG_VOID_RETURN;
|
||||
@ -3063,12 +3061,12 @@ static void mysql_close_free_options(MYSQL *mysql)
|
||||
|
||||
static void mysql_close_free(MYSQL *mysql)
|
||||
{
|
||||
my_free((uchar*) mysql->host_info,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->host_info);
|
||||
my_free(mysql->user);
|
||||
my_free(mysql->passwd);
|
||||
my_free(mysql->db);
|
||||
#if defined(EMBEDDED_LIBRARY) || MYSQL_VERSION_ID >= 50100
|
||||
my_free(mysql->info_buffer,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->info_buffer);
|
||||
mysql->info_buffer= 0;
|
||||
#endif
|
||||
/* Clear pointers for better safety */
|
||||
@ -3176,7 +3174,7 @@ void STDCALL mysql_close(MYSQL *mysql)
|
||||
(*mysql->methods->free_embedded_thd)(mysql);
|
||||
#endif
|
||||
if (mysql->free_me)
|
||||
my_free((uchar*) mysql,MYF(0));
|
||||
my_free(mysql);
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -3313,7 +3311,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql)
|
||||
if (!(result->data=
|
||||
(*mysql->methods->read_rows)(mysql,mysql->fields,mysql->field_count)))
|
||||
{
|
||||
my_free((uchar*) result,MYF(0));
|
||||
my_free(result);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
mysql->affected_rows= result->row_count= result->data->rows;
|
||||
@ -3361,7 +3359,7 @@ static MYSQL_RES * cli_use_result(MYSQL *mysql)
|
||||
if (!(result->row=(MYSQL_ROW)
|
||||
my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME))))
|
||||
{ /* Ptrs: to one row */
|
||||
my_free((uchar*) result,MYF(0));
|
||||
my_free(result);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
result->fields= mysql->fields;
|
||||
@ -3482,19 +3480,19 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
|
||||
add_init_command(&mysql->options,arg);
|
||||
break;
|
||||
case MYSQL_READ_DEFAULT_FILE:
|
||||
my_free(mysql->options.my_cnf_file,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.my_cnf_file);
|
||||
mysql->options.my_cnf_file=my_strdup(arg,MYF(MY_WME));
|
||||
break;
|
||||
case MYSQL_READ_DEFAULT_GROUP:
|
||||
my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.my_cnf_group);
|
||||
mysql->options.my_cnf_group=my_strdup(arg,MYF(MY_WME));
|
||||
break;
|
||||
case MYSQL_SET_CHARSET_DIR:
|
||||
my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.charset_dir);
|
||||
mysql->options.charset_dir=my_strdup(arg,MYF(MY_WME));
|
||||
break;
|
||||
case MYSQL_SET_CHARSET_NAME:
|
||||
my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.charset_name);
|
||||
mysql->options.charset_name=my_strdup(arg,MYF(MY_WME));
|
||||
break;
|
||||
case MYSQL_OPT_PROTOCOL:
|
||||
@ -3503,7 +3501,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
|
||||
case MYSQL_SHARED_MEMORY_BASE_NAME:
|
||||
#ifdef HAVE_SMEM
|
||||
if (mysql->options.shared_memory_base_name != def_shared_memory_base_name)
|
||||
my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.shared_memory_base_name);
|
||||
mysql->options.shared_memory_base_name=my_strdup(arg,MYF(MY_WME));
|
||||
#endif
|
||||
break;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ bool init_errmessage(void)
|
||||
/* Register messages for use with my_error(). */
|
||||
if (my_error_register(get_server_errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST))
|
||||
{
|
||||
x_free((uchar*) errmsgs);
|
||||
my_free(errmsgs);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
@ -155,7 +155,8 @@ Check that the above file is the right version for this program!",
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
x_free((uchar*) *point); /* Free old language */
|
||||
/* Free old language */
|
||||
my_free(*point);
|
||||
if (!(*point= (const char**)
|
||||
my_malloc((size_t) (length+count*sizeof(char*)),MYF(0))))
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n)
|
||||
return TRUE;
|
||||
if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME))))
|
||||
{
|
||||
my_free((uchar*) dbname.str, MYF(0));
|
||||
my_free(dbname.str);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@ -192,8 +192,8 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n)
|
||||
|
||||
Event_queue_element_for_exec::~Event_queue_element_for_exec()
|
||||
{
|
||||
my_free((uchar*) dbname.str, MYF(0));
|
||||
my_free((uchar*) name.str, MYF(0));
|
||||
my_free(dbname.str);
|
||||
my_free(name.str);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -264,7 +264,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
{
|
||||
if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
|
||||
{
|
||||
x_free(table_sort.buffpek);
|
||||
my_free(table_sort.buffpek);
|
||||
table_sort.buffpek= 0;
|
||||
}
|
||||
if (!(table_sort.buffpek=
|
||||
@ -304,13 +304,12 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
error =0;
|
||||
|
||||
err:
|
||||
if (param.tmp_buffer)
|
||||
x_free(param.tmp_buffer);
|
||||
my_free(param.tmp_buffer);
|
||||
if (!subselect || !subselect->is_uncacheable())
|
||||
{
|
||||
x_free((uchar*) sort_keys);
|
||||
my_free(sort_keys);
|
||||
table_sort.sort_keys= 0;
|
||||
x_free((uchar*) buffpek);
|
||||
my_free(buffpek);
|
||||
table_sort.buffpek= 0;
|
||||
table_sort.buffpek_len= 0;
|
||||
}
|
||||
@ -347,32 +346,22 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
|
||||
void filesort_free_buffers(TABLE *table, bool full)
|
||||
{
|
||||
if (table->sort.record_pointers)
|
||||
{
|
||||
my_free((uchar*) table->sort.record_pointers,MYF(0));
|
||||
table->sort.record_pointers=0;
|
||||
}
|
||||
my_free(table->sort.record_pointers);
|
||||
table->sort.record_pointers= NULL;
|
||||
|
||||
if (full)
|
||||
{
|
||||
if (table->sort.sort_keys )
|
||||
{
|
||||
x_free((uchar*) table->sort.sort_keys);
|
||||
table->sort.sort_keys= 0;
|
||||
}
|
||||
if (table->sort.buffpek)
|
||||
{
|
||||
x_free((uchar*) table->sort.buffpek);
|
||||
table->sort.buffpek= 0;
|
||||
table->sort.buffpek_len= 0;
|
||||
}
|
||||
}
|
||||
if (table->sort.addon_buf)
|
||||
{
|
||||
my_free((char *) table->sort.addon_buf, MYF(0));
|
||||
my_free((char *) table->sort.addon_field, MYF(MY_ALLOW_ZERO_PTR));
|
||||
table->sort.addon_buf=0;
|
||||
table->sort.addon_field=0;
|
||||
my_free(table->sort.sort_keys);
|
||||
table->sort.sort_keys= NULL;
|
||||
my_free(table->sort.buffpek);
|
||||
table->sort.buffpek= NULL;
|
||||
table->sort.buffpek_len= NULL;
|
||||
}
|
||||
|
||||
my_free(table->sort.addon_buf);
|
||||
my_free(table->sort.addon_field);
|
||||
table->sort.addon_buf= NULL;
|
||||
table->sort.addon_field= NULL;
|
||||
}
|
||||
|
||||
/** Make a array of string pointers. */
|
||||
@ -413,7 +402,7 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count,
|
||||
if (reinit_io_cache(buffpek_pointers,READ_CACHE,0L,0,0) ||
|
||||
my_b_read(buffpek_pointers, (uchar*) tmp, length))
|
||||
{
|
||||
my_free((char*) tmp, MYF(0));
|
||||
my_free(tmp);
|
||||
tmp=0;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -1035,7 +1035,7 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array,
|
||||
}
|
||||
if (loop == 0 && offset > buffer_size)
|
||||
{
|
||||
my_free(buffer, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(buffer);
|
||||
buffer_size= 0;
|
||||
DBUG_PRINT("info", ("allocate blobs buffer size %u", offset));
|
||||
buffer= (uchar*) my_malloc(offset, MYF(MY_WME));
|
||||
@ -1188,8 +1188,8 @@ int ha_ndbcluster::get_metadata(const char *path)
|
||||
if (readfrm(path, &data, &length) ||
|
||||
packfrm(data, length, &pack_data, &pack_length))
|
||||
{
|
||||
my_free(data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(pack_data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(data);
|
||||
my_free(pack_data);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
@ -1208,8 +1208,8 @@ int ha_ndbcluster::get_metadata(const char *path)
|
||||
DBUG_DUMP("frm", (uchar*) tab->getFrmData(), tab->getFrmLength());
|
||||
error= HA_ERR_TABLE_DEF_CHANGED;
|
||||
}
|
||||
my_free((char*)data, MYF(0));
|
||||
my_free((char*)pack_data, MYF(0));
|
||||
my_free(data);
|
||||
my_free(pack_data);
|
||||
|
||||
if (error)
|
||||
goto err;
|
||||
@ -1235,7 +1235,7 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
|
||||
unsigned sz= index->getNoOfIndexColumns();
|
||||
|
||||
if (data.unique_index_attrid_map)
|
||||
my_free((char*)data.unique_index_attrid_map, MYF(0));
|
||||
my_free(data.unique_index_attrid_map);
|
||||
data.unique_index_attrid_map= (uchar*)my_malloc(sz,MYF(MY_WME));
|
||||
if (data.unique_index_attrid_map == 0)
|
||||
{
|
||||
@ -1313,7 +1313,7 @@ static void ndb_clear_index(NDB_INDEX_DATA &data)
|
||||
{
|
||||
if (data.unique_index_attrid_map)
|
||||
{
|
||||
my_free((char*)data.unique_index_attrid_map, MYF(0));
|
||||
my_free(data.unique_index_attrid_map);
|
||||
}
|
||||
if (data.index_stat)
|
||||
{
|
||||
@ -5399,15 +5399,15 @@ int ha_ndbcluster::create(const char *name,
|
||||
DBUG_RETURN(1);
|
||||
if (packfrm(data, length, &pack_data, &pack_length))
|
||||
{
|
||||
my_free((char*)data, MYF(0));
|
||||
my_free(data);
|
||||
DBUG_RETURN(2);
|
||||
}
|
||||
DBUG_PRINT("info",
|
||||
("setFrm data: 0x%lx len: %lu", (long) pack_data,
|
||||
(ulong) pack_length));
|
||||
tab.setFrm(pack_data, pack_length);
|
||||
my_free((char*)data, MYF(0));
|
||||
my_free((char*)pack_data, MYF(0));
|
||||
my_free(data);
|
||||
my_free(pack_data);
|
||||
|
||||
/*
|
||||
Check for disk options
|
||||
@ -5751,8 +5751,8 @@ int ha_ndbcluster::create_handler_files(const char *file,
|
||||
packfrm(data, length, &pack_data, &pack_length))
|
||||
{
|
||||
DBUG_PRINT("info", ("Missing frm for %s", m_tabname));
|
||||
my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(data);
|
||||
my_free(pack_data);
|
||||
error= 1;
|
||||
}
|
||||
else
|
||||
@ -5766,8 +5766,8 @@ int ha_ndbcluster::create_handler_files(const char *file,
|
||||
set_ndb_err(current_thd, dict->getNdbError());
|
||||
error= ndb_to_mysql_error(&dict->getNdbError());
|
||||
}
|
||||
my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(data);
|
||||
my_free(pack_data);
|
||||
}
|
||||
|
||||
set_ndb_share_state(m_share, NSS_INITIAL);
|
||||
@ -6565,7 +6565,7 @@ ha_ndbcluster::~ha_ndbcluster()
|
||||
free_share(&m_share);
|
||||
}
|
||||
release_metadata(thd, ndb);
|
||||
my_free(m_blobs_buffer, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(m_blobs_buffer);
|
||||
m_blobs_buffer= 0;
|
||||
|
||||
// Check for open cursor/transaction
|
||||
@ -6911,7 +6911,7 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db,
|
||||
|
||||
DBUG_RETURN(0);
|
||||
err:
|
||||
my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(data);
|
||||
if (share)
|
||||
{
|
||||
/* ndb_share reference temporary free */
|
||||
@ -7177,8 +7177,8 @@ int ndbcluster_find_all_files(THD *thd)
|
||||
free_share(&share);
|
||||
}
|
||||
}
|
||||
my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((char*) pack_data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(data);
|
||||
my_free(pack_data);
|
||||
|
||||
mysql_mutex_lock(&LOCK_open);
|
||||
if (discover)
|
||||
@ -8681,7 +8681,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
|
||||
if (my_hash_insert(&ndbcluster_open_tables, (uchar*) share))
|
||||
{
|
||||
free_root(&share->mem_root, MYF(0));
|
||||
my_free((uchar*) share, 0);
|
||||
my_free(share);
|
||||
*root_ptr= old_root;
|
||||
if (!have_lock)
|
||||
mysql_mutex_unlock(&ndbcluster_mutex);
|
||||
@ -8752,7 +8752,7 @@ void ndbcluster_real_free_share(NDB_SHARE **share)
|
||||
}
|
||||
#endif
|
||||
free_root(&(*share)->mem_root, MYF(0));
|
||||
my_free((uchar*) *share, MYF(0));
|
||||
my_free(*share);
|
||||
*share= 0;
|
||||
|
||||
dbug_print_open_tables();
|
||||
@ -10076,7 +10076,7 @@ int ha_ndbcluster::set_range_data(void *tab_ref, partition_info *part_info)
|
||||
}
|
||||
tab->setRangeListData(range_data, sizeof(int32)*part_info->num_parts);
|
||||
error:
|
||||
my_free((char*)range_data, MYF(0));
|
||||
my_free(range_data);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
@ -10113,7 +10113,7 @@ int ha_ndbcluster::set_list_data(void *tab_ref, partition_info *part_info)
|
||||
}
|
||||
tab->setRangeListData(list_data, 2*sizeof(int32)*part_info->num_list_values);
|
||||
error:
|
||||
my_free((char*)list_data, MYF(0));
|
||||
my_free(list_data);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -1020,7 +1020,7 @@ static void ndbcluster_get_schema(NDB_SHARE *share,
|
||||
ptrdiff);
|
||||
if (ret != 0)
|
||||
{
|
||||
my_free(blobs_buffer, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(blobs_buffer);
|
||||
DBUG_PRINT("info", ("blob read error"));
|
||||
DBUG_ASSERT(FALSE);
|
||||
}
|
||||
@ -1071,7 +1071,7 @@ static void ndbcluster_get_schema(NDB_SHARE *share,
|
||||
field++;
|
||||
s->type= ((Field_long *)*field)->val_int();
|
||||
/* free blobs buffer */
|
||||
my_free(blobs_buffer, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(blobs_buffer);
|
||||
dbug_tmp_restore_column_map(table->read_set, old_map);
|
||||
}
|
||||
|
||||
@ -1739,7 +1739,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
|
||||
old->getObjectVersion() != altered_table->getObjectVersion())
|
||||
dict->putTable(altered_table);
|
||||
|
||||
my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(data);
|
||||
data= NULL;
|
||||
if ((error= unpackfrm(&data, &length,
|
||||
(const uchar*) altered_table->getFrmData())) ||
|
||||
@ -1772,8 +1772,8 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
|
||||
|
||||
mysql_mutex_unlock(&LOCK_open);
|
||||
}
|
||||
my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(data);
|
||||
my_free(pack_data);
|
||||
}
|
||||
|
||||
// If only frm was changed continue replicating
|
||||
@ -3507,8 +3507,8 @@ ndb_binlog_thread_handle_data_event(Ndb *ndb, NdbEventOperation *pOp,
|
||||
|
||||
if (share->flags & NSF_BLOB_FLAG)
|
||||
{
|
||||
my_free(blobs_buffer[0], MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(blobs_buffer[1], MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(blobs_buffer[0]);
|
||||
my_free(blobs_buffer[1]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -3580,7 +3580,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key,
|
||||
ndb_schema_object->key_length= length;
|
||||
if (my_hash_insert(&ndb_schema_objects, (uchar*) ndb_schema_object))
|
||||
{
|
||||
my_free((uchar*) ndb_schema_object, 0);
|
||||
my_free(ndb_schema_object);
|
||||
break;
|
||||
}
|
||||
mysql_mutex_init(key_ndb_schema_object_mutex, &ndb_schema_object->mutex, MY_MUTEX_INIT_FAST);
|
||||
@ -3612,7 +3612,7 @@ static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object,
|
||||
DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
|
||||
my_hash_delete(&ndb_schema_objects, (uchar*) *ndb_schema_object);
|
||||
mysql_mutex_destroy(&(*ndb_schema_object)->mutex);
|
||||
my_free((uchar*) *ndb_schema_object, MYF(0));
|
||||
my_free(*ndb_schema_object);
|
||||
*ndb_schema_object= 0;
|
||||
}
|
||||
else
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user