summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-12-11 17:16:15 +0100
committerSergei Golubchik <serg@mariadb.org>2017-01-15 07:41:13 +0100
commit1282eb694c9fb18cac6bace643b4ce275a6a5689 (patch)
treebe049d91119db4a038144e4742a9c0f48f9c2735
parentebb8c9fb26f86cff8c0d81bd2415f415cef952bb (diff)
downloadmariadb-git-1282eb694c9fb18cac6bace643b4ce275a6a5689.tar.gz
cleanup: make malloc_size_cb_func always defined
-rw-r--r--mysys/my_malloc.c15
-rw-r--r--sql/mysqld.cc5
2 files changed, 10 insertions, 10 deletions
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index e533230106e..dc02d3896bd 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -48,7 +48,6 @@ static inline size_t malloc_size_and_flag(void *p, my_bool *is_thread_specific)
#define MALLOC_FIX_POINTER_FOR_FREE(p) (((char*) (p)) - MALLOC_PREFIX_SIZE)
#endif /* SAFEMALLOC */
-static MALLOC_SIZE_CB malloc_size_cb_func= NULL;
/**
Inform application that memory usage has changed
@@ -59,17 +58,19 @@ static MALLOC_SIZE_CB malloc_size_cb_func= NULL;
The type os size is long long, to be able to handle negative numbers to
decrement the memory usage
+
+ @return 0 - ok
+ 1 - failure, abort the allocation
*/
+static void dummy(long long size __attribute__((unused)),
+ my_bool is_thread_specific __attribute__((unused)))
+{}
-static void update_malloc_size(long long size, my_bool is_thread_specific)
-{
- if (malloc_size_cb_func)
- malloc_size_cb_func(size, is_thread_specific);
-}
+static MALLOC_SIZE_CB update_malloc_size= dummy;
void set_malloc_size_cb(MALLOC_SIZE_CB func)
{
- malloc_size_cb_func= func;
+ update_malloc_size= func ? func : dummy;
}
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index adb1b273b80..96baaf25287 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3989,7 +3989,7 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific)
{
THD *thd= current_thd;
- if (likely(is_thread_specific)) /* If thread specific memory */
+ if (is_thread_specific) /* If thread specific memory */
{
/*
When thread specfic is set, both mysqld_server_initialized and thd
@@ -4006,8 +4006,7 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific)
else if (likely(thd))
{
DBUG_PRINT("info", ("global thd memory_used: %lld size: %lld",
- (longlong) thd->status_var.global_memory_used,
- size));
+ (longlong) thd->status_var.global_memory_used, size));
thd->status_var.global_memory_used+= size;
}
else