diff options
author | Monty <monty@mariadb.org> | 2018-01-28 15:54:17 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-01-28 15:54:17 +0200 |
commit | ffcedfab46a7b2fad9b309aa1930e14068d968aa (patch) | |
tree | ed176889f70c5ae88b5cba027804163b6a106bb7 /mysys/my_malloc.c | |
parent | 84514ec643aafe74b7ac256fa485013e222f942e (diff) | |
download | mariadb-git-ffcedfab46a7b2fad9b309aa1930e14068d968aa.tar.gz |
Added TRASH_FREED_MEMORY compilation option
One can use -DTRASH_FREED_MEMORY to enable TRASH
macros. Useful to do when one suspects that there
is accesses to freed memory.
Extended my_free() to TRASH freed memory
Diffstat (limited to 'mysys/my_malloc.c')
-rw-r--r-- | mysys/my_malloc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index 719c13a040e..2b34c89f5e4 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -214,6 +214,13 @@ void my_free(void *ptr) my_bool old_flags; old_size= MALLOC_SIZE_AND_FLAG(ptr, &old_flags); update_malloc_size(- (longlong) old_size - MALLOC_PREFIX_SIZE, old_flags); +#ifndef SAFEMALLOC + /* + Trash memory if not safemalloc. We don't have to do this if safemalloc + is used as safemalloc will also do trashing + */ + TRASH_FREE(ptr, old_size); +#endif sf_free(MALLOC_FIX_POINTER_FOR_FREE(ptr)); } DBUG_VOID_RETURN; |