mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
fix a crash after set_malloc_size_cb(NULL)
also, remove a now-redundant if()
followup for f33367f2ab
This commit is contained in:
@@ -53,7 +53,7 @@ MALLOC_SIZE_CB update_malloc_size= dummy;
|
||||
|
||||
void set_malloc_size_cb(MALLOC_SIZE_CB func)
|
||||
{
|
||||
update_malloc_size= func;
|
||||
update_malloc_size= func ? func : dummy;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,11 +107,8 @@ void *my_malloc(PSI_memory_key key, size_t size, myf my_flags)
|
||||
int flag= MY_TEST(my_flags & MY_THREAD_SPECIFIC);
|
||||
mh->m_size= size | flag;
|
||||
mh->m_key= PSI_CALL_memory_alloc(key, size, & mh->m_owner);
|
||||
if (update_malloc_size != dummy)
|
||||
{
|
||||
mh->m_size|=2;
|
||||
update_malloc_size(size + HEADER_SIZE, flag);
|
||||
}
|
||||
mh->m_size|=2;
|
||||
update_malloc_size(size + HEADER_SIZE, flag);
|
||||
point= HEADER_TO_USER(mh);
|
||||
if (my_flags & MY_ZEROFILL)
|
||||
bzero(point, size);
|
||||
@@ -176,7 +173,7 @@ void *my_realloc(PSI_memory_key key, void *old_point, size_t size, myf my_flags)
|
||||
{
|
||||
mh->m_size= size | old_flags;
|
||||
mh->m_key= PSI_CALL_memory_realloc(key, old_size, size, & mh->m_owner);
|
||||
if (update_malloc_size != dummy && (old_flags & 2))
|
||||
if (old_flags & 2)
|
||||
update_malloc_size((longlong)size - (longlong)old_size, old_flags & 1);
|
||||
point= HEADER_TO_USER(mh);
|
||||
}
|
||||
@@ -207,7 +204,7 @@ void my_free(void *ptr)
|
||||
old_flags= mh->m_size & 3;
|
||||
PSI_CALL_memory_free(mh->m_key, old_size, mh->m_owner);
|
||||
|
||||
if (update_malloc_size != dummy && (old_flags & 2))
|
||||
if (old_flags & 2)
|
||||
update_malloc_size(- (longlong) old_size - HEADER_SIZE, old_flags & 1);
|
||||
|
||||
#ifndef SAFEMALLOC
|
||||
|
||||
Reference in New Issue
Block a user