summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2017-12-18 17:15:48 +0400
committerSergey Vojtovich <svoj@mariadb.org>2017-12-19 19:10:54 +0400
commit2cd316911309e3db4007aa224f7874bfbeb14032 (patch)
tree53ffd4ab4d99f7ff37dfa31407c2199a222baf5c
parented7e4b68ed59fb7c34dc06625dfe378e71d1e8a7 (diff)
downloadmariadb-git-2cd316911309e3db4007aa224f7874bfbeb14032.tar.gz
MDEV-14265 - RPMLint warning: shared-lib-calls-exit
find_type_or_exit() client helper did exit(1) on error, exit(1) moved to clients. mysql_read_default_options() did exit(1) on error, error is passed through and handled now. my_str_malloc_default() did exit(1) on error, replaced my_str_ allocator functions with normal my_malloc()/my_realloc()/my_free(). sql_connect.cc did many exit(1) on hash initialisation failure. Removed error check since my_hash_init() never fails. my_malloc() did exit(1) on error. Replaced with abort(). my_load_defaults() did exit(1) on error, replaced with return 2. my_load_defaults() still does exit(0) when invoked with --print-defaults.
-rw-r--r--client/mysql.cc8
-rw-r--r--client/mysqladmin.cc8
-rw-r--r--client/mysqlbinlog.cc19
-rw-r--r--client/mysqlcheck.c8
-rw-r--r--client/mysqldump.c8
-rw-r--r--client/mysqlimport.c8
-rw-r--r--client/mysqlshow.c8
-rw-r--r--client/mysqlslap.c8
-rw-r--r--client/mysqltest.cc8
-rw-r--r--extra/mariabackup/xtrabackup.cc8
-rw-r--r--include/m_string.h9
-rw-r--r--include/mysql.h.pp2
-rw-r--r--include/typelib.h2
-rw-r--r--libmysqld/libmysqld.c3
-rw-r--r--mysql-test/t/xml.test2
-rw-r--r--mysys/my_default.c6
-rw-r--r--mysys/my_malloc.c2
-rw-r--r--mysys/typelib.c12
-rw-r--r--sql-common/client.c7
-rw-r--r--sql/mysqld.cc21
-rw-r--r--sql/sql_connect.cc49
-rw-r--r--strings/CMakeLists.txt2
-rw-r--r--strings/ctype-tis620.c8
-rw-r--r--strings/my_vsnprintf.c6
-rw-r--r--strings/str_alloc.c41
-rw-r--r--strings/xml.c9
26 files changed, 110 insertions, 162 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index c043d054ea5..977085ebd42 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1793,8 +1793,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case OPT_MYSQL_PROTOCOL:
#ifndef EMBEDDED_LIBRARY
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
#endif
break;
case OPT_SERVER_ARG:
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index ffdc73f99ad..897c2eb41c3 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -298,8 +298,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif
break;
case OPT_MYSQL_PROTOCOL:
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
break;
}
return 0;
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index c103061bbc5..b871a70ef01 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -1649,8 +1649,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
remote_opt= 1;
break;
case OPT_MYSQL_PROTOCOL:
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
break;
case OPT_START_DATETIME:
start_datetime= convert_str_to_timestamp(start_datetime_str);
@@ -1663,8 +1667,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_base64_output_mode= BASE64_OUTPUT_ALWAYS;
else
{
- opt_base64_output_mode= (enum_base64_output_mode)
- (find_type_or_exit(argument, &base64_output_mode_typelib, opt->name)-1);
+ int val;
+
+ if ((val= find_type_with_warning(argument, &base64_output_mode_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
+ opt_base64_output_mode= (enum_base64_output_mode) (val - 1);
}
break;
case OPT_REWRITE_DB: // db_from->db_to
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index c4ac58973f8..47cb38751eb 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -367,8 +367,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
print_version(); exit(0);
break;
case OPT_MYSQL_PROTOCOL:
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
break;
}
diff --git a/client/mysqldump.c b/client/mysqldump.c
index aead4caf506..5c0ec2a5510 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -956,8 +956,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
}
case (int) OPT_MYSQL_PROTOCOL:
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
break;
}
return 0;
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 7f03cb355f8..9c84d4a62a6 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -249,8 +249,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
#endif
case OPT_MYSQL_PROTOCOL:
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
break;
case '#':
DBUG_PUSH(argument ? argument : "d:t:o");
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 6f434d6770d..f851c15106e 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -328,8 +328,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif
break;
case OPT_MYSQL_PROTOCOL:
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
break;
case '#':
DBUG_PUSH(argument ? argument : "d:t:o");
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index a78bf35d51b..6a0b214305c 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -779,8 +779,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif
break;
case OPT_MYSQL_PROTOCOL:
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
break;
case '#':
DBUG_PUSH(argument ? argument : default_dbug_option);
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 155d0c4c092..2200462b2fe 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -7292,8 +7292,12 @@ get_one_option(int optid, const struct my_option *opt, char *argument)
exit(0);
case OPT_MYSQL_PROTOCOL:
#ifndef EMBEDDED_LIBRARY
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
#endif
break;
case '?':
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index eb1cbf4748d..437fc4aa7f9 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -1380,8 +1380,12 @@ xb_get_one_option(int optid,
case OPT_PROTOCOL:
if (argument)
{
- opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
- opt->name);
+ if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ opt->name)) <= 0)
+ {
+ sf_leaking_memory= 1; /* no memory leak reports here */
+ exit(1);
+ }
}
break;
#include "sslopt-case.h"
diff --git a/include/m_string.h b/include/m_string.h
index 7437ea8b7cd..d088b510de5 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -64,15 +64,6 @@
extern "C" {
#endif
-/*
- my_str_malloc(), my_str_realloc() and my_str_free() are assigned to
- implementations in strings/alloc.c, but can be overridden in
- the calling program.
- */
-extern void *(*my_str_malloc)(size_t);
-extern void *(*my_str_realloc)(void *, size_t);
-extern void (*my_str_free)(void *);
-
#ifdef DBUG_OFF
#if defined(HAVE_STPCPY) && MY_GNUC_PREREQ(3, 4) && !defined(__INTEL_COMPILER)
#define strmov(A,B) __builtin_stpcpy((A),(B))
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index 32d87b7391c..8936a716b90 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -221,8 +221,6 @@ typedef struct st_typelib {
extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
extern int find_type_with_warning(const char *x, TYPELIB *typelib,
const char *option);
-extern int find_type_or_exit(const char *x, TYPELIB *typelib,
- const char *option);
extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
extern const char *get_type(TYPELIB *typelib,unsigned int nr);
diff --git a/include/typelib.h b/include/typelib.h
index 4504bea4ff7..ab5a0f0d258 100644
--- a/include/typelib.h
+++ b/include/typelib.h
@@ -29,8 +29,6 @@ typedef struct st_typelib { /* Different types saved here */
extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
extern int find_type_with_warning(const char *x, TYPELIB *typelib,
const char *option);
-extern int find_type_or_exit(const char *x, TYPELIB *typelib,
- const char *option);
#define FIND_TYPE_BASIC 0
/** makes @c find_type() require the whole name, no prefix */
#define FIND_TYPE_NO_PREFIX (1 << 0)
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index 36728cf573c..543ab86643e 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -121,6 +121,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
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;
+
+ if (mysql->options.protocol == UINT_MAX32)
+ goto error;
}
if (!db || !db[0])
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index 371fcb72b0d..ae7e9058e26 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -713,7 +713,7 @@ FROM t1;
SELECT UPDATEXML(txt, CONCAT('//', REPEAT('b', 63)), '63/63+') FROM t1;
DROP TABLE t1;
-# This will call my_str_realloc_mysqld()
+# This will call realloc()
CREATE TABLE t1 (a TEXT);
INSERT INTO t1 VALUES (CONCAT('<a><', REPEAT('b',128),'>b128</',REPEAT('b',128),'><',REPEAT('c',512),'>c512</',REPEAT('c',512),'></a>'));
SELECT ExtractValue (a, CONCAT('//',REPEAT('c',512))) AS c512 FROM t1;
diff --git a/mysys/my_default.c b/mysys/my_default.c
index 655e9a57747..dba22c4e58b 100644
--- a/mysys/my_default.c
+++ b/mysys/my_default.c
@@ -487,8 +487,7 @@ int load_defaults(const char *conf_file, const char **groups,
easily command line options override options in configuration files
NOTES
- In case of fatal error, the function will print a warning and do
- exit(1)
+ In case of fatal error, the function will print a warning and returns 2
To free used memory one should call free_defaults() with the argument
that was put in *argv
@@ -641,8 +640,7 @@ int my_load_defaults(const char *conf_file, const char **groups,
err:
fprintf(stderr,"Fatal error in defaults handling. Program aborted\n");
- exit(1);
- return 0; /* Keep compiler happy */
+ return 2;
}
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index dc02d3896bd..719c13a040e 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -109,7 +109,7 @@ void *my_malloc(size_t size, myf my_flags)
my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_WAITTANG +
ME_NOREFRESH + ME_FATALERROR),size);
if (my_flags & MY_FAE)
- exit(1);
+ abort();
}
else
{
diff --git a/mysys/typelib.c b/mysys/typelib.c
index 96842b1a3ad..9ca0847570f 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -45,18 +45,6 @@ int find_type_with_warning(const char *x, TYPELIB *typelib, const char *option)
}
-int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option)
-{
- int res;
- if ((res= find_type_with_warning(x, typelib, option)) <= 0)
- {
- sf_leaking_memory= 1; /* no memory leak reports here */
- exit(1);
- }
- return res;
-}
-
-
/**
Search after a string in a list of strings. Endspace in x is not compared.
diff --git a/sql-common/client.c b/sql-common/client.c
index ea686a79a1f..da18a0fdea1 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1232,11 +1232,12 @@ void mysql_read_default_options(struct st_mysql_options *options,
options->max_allowed_packet= atoi(opt_arg);
break;
case OPT_protocol:
- if ((options->protocol= find_type(opt_arg, &sql_protocol_typelib,
+ if (options->protocol != UINT_MAX32 &&
+ (options->protocol= find_type(opt_arg, &sql_protocol_typelib,
FIND_TYPE_BASIC)) <= 0)
{
fprintf(stderr, "Unknown option to protocol: %s\n", opt_arg);
- exit(1);
+ options->protocol= UINT_MAX32;
}
break;
case OPT_shared_memory_base_name:
@@ -3133,6 +3134,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
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;
+ if (mysql->options.protocol == UINT_MAX32)
+ goto error;
}
/* Some empty-string-tests are done because of ODBC */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 8b7fdd2f705..227c3eb6f99 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3542,8 +3542,6 @@ void my_message_sql(uint error, const char *str, myf MyFlags)
extern "C" void *my_str_malloc_mysqld(size_t size);
-extern "C" void my_str_free_mysqld(void *ptr);
-extern "C" void *my_str_realloc_mysqld(void *ptr, size_t size);
void *my_str_malloc_mysqld(size_t size)
{
@@ -3551,17 +3549,6 @@ void *my_str_malloc_mysqld(size_t size)
}
-void my_str_free_mysqld(void *ptr)
-{
- my_free(ptr);
-}
-
-void *my_str_realloc_mysqld(void *ptr, size_t size)
-{
- return my_realloc(ptr, size, MYF(MY_FAE));
-}
-
-
#ifdef __WIN__
pthread_handler_t handle_shutdown(void *arg)
@@ -3617,14 +3604,8 @@ check_enough_stack_size(int recurse_level)
}
-/*
- Initialize my_str_malloc() and my_str_free()
-*/
static void init_libstrings()
{
- my_str_malloc= &my_str_malloc_mysqld;
- my_str_free= &my_str_free_mysqld;
- my_str_realloc= &my_str_realloc_mysqld;
#ifndef EMBEDDED_LIBRARY
my_string_stack_guard= check_enough_stack_size;
#endif
@@ -3635,7 +3616,7 @@ ulonglong my_pcre_frame_size;
static void init_pcre()
{
pcre_malloc= pcre_stack_malloc= my_str_malloc_mysqld;
- pcre_free= pcre_stack_free= my_str_free_mysqld;
+ pcre_free= pcre_stack_free= my_free;
pcre_stack_guard= check_enough_stack_size_slow;
/* See http://pcre.org/original/doc/html/pcrestack.html */
my_pcre_frame_size= -pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0);
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index ac5b6ab29a2..d3ef245209d 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -314,13 +314,9 @@ extern "C" void free_user(struct user_conn *uc)
void init_max_user_conn(void)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
- if (my_hash_init(&hash_user_connections,system_charset_info,max_connections,
- 0,0, (my_hash_get_key) get_key_conn,
- (my_hash_free_key) free_user, 0))
- {
- sql_print_error("Initializing hash_user_connections failed.");
- exit(1);
- }
+ my_hash_init(&hash_user_connections, system_charset_info, max_connections,
+ 0, 0, (my_hash_get_key) get_key_conn,
+ (my_hash_free_key) free_user, 0);
#endif
}
@@ -479,24 +475,16 @@ void init_user_stats(USER_STATS *user_stats,
void init_global_user_stats(void)
{
- if (my_hash_init(&global_user_stats, system_charset_info, max_connections,
- 0, 0, (my_hash_get_key) get_key_user_stats,
- (my_hash_free_key)free_user_stats, 0))
- {
- sql_print_error("Initializing global_user_stats failed.");
- exit(1);
- }
+ my_hash_init(&global_user_stats, system_charset_info, max_connections,
+ 0, 0, (my_hash_get_key) get_key_user_stats,
+ (my_hash_free_key) free_user_stats, 0);
}
void init_global_client_stats(void)
{
- if (my_hash_init(&global_client_stats, system_charset_info, max_connections,
- 0, 0, (my_hash_get_key) get_key_user_stats,
- (my_hash_free_key)free_user_stats, 0))
- {
- sql_print_error("Initializing global_client_stats failed.");
- exit(1);
- }
+ my_hash_init(&global_client_stats, system_charset_info, max_connections,
+ 0, 0, (my_hash_get_key) get_key_user_stats,
+ (my_hash_free_key) free_user_stats, 0);
}
extern "C" uchar *get_key_table_stats(TABLE_STATS *table_stats, size_t *length,
@@ -513,12 +501,9 @@ extern "C" void free_table_stats(TABLE_STATS* table_stats)
void init_global_table_stats(void)
{
- if (my_hash_init(&global_table_stats, system_charset_info, max_connections,
- 0, 0, (my_hash_get_key) get_key_table_stats,
- (my_hash_free_key)free_table_stats, 0)) {
- sql_print_error("Initializing global_table_stats failed.");
- exit(1);
- }
+ my_hash_init(&global_table_stats, system_charset_info, max_connections,
+ 0, 0, (my_hash_get_key) get_key_table_stats,
+ (my_hash_free_key) free_table_stats, 0);
}
extern "C" uchar *get_key_index_stats(INDEX_STATS *index_stats, size_t *length,
@@ -535,13 +520,9 @@ extern "C" void free_index_stats(INDEX_STATS* index_stats)
void init_global_index_stats(void)
{
- if (my_hash_init(&global_index_stats, system_charset_info, max_connections,
- 0, 0, (my_hash_get_key) get_key_index_stats,
- (my_hash_free_key)free_index_stats, 0))
- {
- sql_print_error("Initializing global_index_stats failed.");
- exit(1);
- }
+ my_hash_init(&global_index_stats, system_charset_info, max_connections,
+ 0, 0, (my_hash_get_key) get_key_index_stats,
+ (my_hash_free_key) free_index_stats, 0);
}
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt
index 32a3f06c861..65eeb457f2d 100644
--- a/strings/CMakeLists.txt
+++ b/strings/CMakeLists.txt
@@ -20,7 +20,7 @@ SET(STRINGS_SOURCES bchange.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c
ctype-latin1.c ctype-mb.c ctype-simple.c ctype-sjis.c ctype-tis620.c ctype-uca.c
ctype-ucs2.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype.c decimal.c dtoa.c int2str.c
is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c
- str2int.c str_alloc.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c
+ str2int.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c
strxmov.c strxnmov.c xml.c
strmov_overlapp.c
my_strchr.c strcont.c strappend.c)
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index bd8efeff1ec..5284109b816 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -524,7 +524,7 @@ int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)),
tc1= buf;
if ((len1 + len2 +2) > (int) sizeof(buf))
- tc1= (uchar*) my_str_malloc(len1+len2+2);
+ tc1= (uchar*) my_malloc(len1+len2+2, MYF(MY_FAE));
tc2= tc1 + len1+1;
memcpy((char*) tc1, (char*) s1, len1);
tc1[len1]= 0; /* if length(s1)> len1, need to put 'end of string' */
@@ -534,7 +534,7 @@ int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)),
thai2sortable(tc2, len2);
i= strcmp((char*)tc1, (char*)tc2);
if (tc1 != buf)
- my_str_free(tc1);
+ my_free(tc1);
return i;
}
@@ -555,7 +555,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)),
a= buf;
if ((a_length + b_length +2) > (int) sizeof(buf))
- alloced= a= (uchar*) my_str_malloc(a_length+b_length+2);
+ alloced= a= (uchar*) my_malloc(a_length+b_length+2, MYF(MY_FAE));
b= a + a_length+1;
memcpy((char*) a, (char*) a0, a_length);
@@ -604,7 +604,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)),
ret:
if (alloced)
- my_str_free(alloced);
+ my_free(alloced);
return res;
}
diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c
index 4178b20789d..134fdfc57b8 100644
--- a/strings/my_vsnprintf.c
+++ b/strings/my_vsnprintf.c
@@ -755,14 +755,14 @@ int my_vfprintf(FILE *stream, const char* format, va_list args)
and try again.
*/
if (alloc)
- (*my_str_free)(p);
+ my_free(p);
else
alloc= 1;
new_len= cur_len*2;
if (new_len < cur_len)
return 0; /* Overflow */
cur_len= new_len;
- p= (*my_str_malloc)(cur_len);
+ p= my_malloc(cur_len, MYF(MY_FAE));
if (!p)
return 0;
}
@@ -770,7 +770,7 @@ int my_vfprintf(FILE *stream, const char* format, va_list args)
if (fputs(p, stream) < 0)
ret= -1;
if (alloc)
- (*my_str_free)(p);
+ my_free(p);
return ret;
}
diff --git a/strings/str_alloc.c b/strings/str_alloc.c
deleted file mode 100644
index 91246603f2e..00000000000
--- a/strings/str_alloc.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (c) 2005, 2006 MySQL AB
- Copyright (c) 2009-2011, Monty Program Ab
- Use is subject to license terms.
- Copyright (c) 2009-2011, Monty Program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
-
-#include "strings_def.h"
-
-static void *my_str_malloc_default(size_t size)
-{
- void *ret= malloc(size);
- if (!ret)
- exit(1);
- return ret;
-}
-
-static void my_str_free_default(void *ptr)
-{
- free(ptr);
-}
-
-void *my_str_realloc_default(void *ptr, size_t size)
-{
- return realloc(ptr, size);
-}
-
-void *(*my_str_malloc)(size_t)= &my_str_malloc_default;
-void (*my_str_free)(void *)= &my_str_free_default;
-void *(*my_str_realloc)(void *, size_t)= &my_str_realloc_default;
diff --git a/strings/xml.c b/strings/xml.c
index 4685a04faec..b5fed6a6760 100644
--- a/strings/xml.c
+++ b/strings/xml.c
@@ -17,6 +17,7 @@
#include "strings_def.h"
#include "m_string.h"
#include "my_xml.h"
+#include "my_sys.h"
#define MY_XML_UNKNOWN 'U'
@@ -231,13 +232,13 @@ static int my_xml_attr_ensure_space(MY_XML_PARSER *st, size_t len)
if (!st->attr.buffer)
{
- st->attr.buffer= (char *) my_str_malloc(st->attr.buffer_size);
+ st->attr.buffer= (char *) my_malloc(st->attr.buffer_size, MYF(0));
if (st->attr.buffer)
memcpy(st->attr.buffer, st->attr.static_buffer, ofs + 1 /*term. zero */);
}
else
- st->attr.buffer= (char *) my_str_realloc(st->attr.buffer,
- st->attr.buffer_size);
+ st->attr.buffer= (char *) my_realloc(st->attr.buffer,
+ st->attr.buffer_size, MYF(0));
st->attr.start= st->attr.buffer;
st->attr.end= st->attr.start + ofs;
@@ -507,7 +508,7 @@ void my_xml_parser_free(MY_XML_PARSER *p)
{
if (p->attr.buffer)
{
- my_str_free(p->attr.buffer);
+ my_free(p->attr.buffer);
p->attr.buffer= NULL;
}
}