summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2013-10-01 16:39:29 +0400
committerAlexander Barkov <bar@mnogosearch.org>2013-10-01 16:39:29 +0400
commit59311f3eadd4087f1ea5d32af2ceb27b56ea243a (patch)
treeb6433bacd2e06f838ccd178e2e3b55bda70351cc
parentccb1344fe962d84eb627cc3c0ca33220764bd0f3 (diff)
downloadmariadb-git-59311f3eadd4087f1ea5d32af2ceb27b56ea243a.tar.gz
Make PCRE use my_malloc() and my_free().
This patch also makes libstrings use my_malloc() and my_free() in embedded server. Previously, embeddes server used malloc() and free() in libstrings.
-rw-r--r--sql/mysqld.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 2302f59e5dc..36271886f66 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3278,7 +3278,6 @@ void my_message_sql(uint error, const char *str, myf MyFlags)
}
-#ifndef EMBEDDED_LIBRARY
extern "C" void *my_str_malloc_mysqld(size_t size);
extern "C" void my_str_free_mysqld(void *ptr);
@@ -3292,7 +3291,24 @@ void my_str_free_mysqld(void *ptr)
{
my_free(ptr);
}
-#endif /* EMBEDDED_LIBRARY */
+
+
+/*
+ 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;
+}
+
+
+static void init_pcre()
+{
+ pcre_malloc= pcre_stack_malloc= my_str_malloc_mysqld;
+ pcre_free= pcre_stack_free= my_str_free_mysqld;
+}
+
#ifdef __WIN__
@@ -3600,6 +3616,7 @@ static int init_common_variables()
set_current_thd(0);
set_malloc_size_cb(my_malloc_size_cb_func);
+ init_libstrings();
tzset(); // Set tzname
sf_leaking_memory= 0; // no memory leaks from now on
@@ -3902,6 +3919,7 @@ static int init_common_variables()
if (item_create_init())
return 1;
item_init();
+ init_pcre();
#ifndef EMBEDDED_LIBRARY
my_string_stack_guard= check_enough_stack_size;
#endif
@@ -5059,12 +5077,6 @@ int mysqld_main(int argc, char **argv)
#endif
/*
- Initialize my_str_malloc() and my_str_free()
- */
- my_str_malloc= &my_str_malloc_mysqld;
- my_str_free= &my_str_free_mysqld;
-
- /*
init signals & alarm
After this we can't quit by a simple unireg_abort
*/