From 565f74102e81d95cfcb24546e16fcfbdc556a49a Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 30 May 2017 15:57:28 +0900 Subject: [PATCH] Bug 1368932 - Fill the replace-malloc malloc_table_t with the real allocator as a fallback. r=njn Until now, the malloc implementation functions would call the replace-malloc functions if they exist, and fallback to the real allocator in no such function exists. Instead of doing this, we now fill the empty slots in the malloc_table_t with the real allocator functions. --HG-- extra : rebase_source : b54634f23188906939e4dc01fc5a3007de0f3f2c --- memory/build/replace_malloc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/memory/build/replace_malloc.c b/memory/build/replace_malloc.c index c9bd979a5db4..619b7523c777 100644 --- a/memory/build/replace_malloc.c +++ b/memory/build/replace_malloc.c @@ -129,6 +129,12 @@ replace_malloc_init_funcs() replace_malloc_table.name = REPLACE_MALLOC_GET_FUNC(handle, name); #include "malloc_decls.h" } + +#define MALLOC_DECL(name, ...) \ + if (!replace_malloc_table.name) { \ + replace_malloc_table.name = je_ ## name; \ + } +#include "malloc_decls.h" } /* @@ -174,11 +180,7 @@ init() { \ if (MOZ_UNLIKELY(!replace_malloc_initialized)) \ init(); \ - if (MOZ_LIKELY(!replace_malloc_table.name)) { \ - return je_ ## name(ARGS_HELPER(ARGS, ##__VA_ARGS__)); \ - } else { \ - return replace_malloc_table.name(ARGS_HELPER(ARGS, ##__VA_ARGS__)); \ - } \ + return replace_malloc_table.name(ARGS_HELPER(ARGS, ##__VA_ARGS__)); \ } #define GENERIC_MALLOC_DECL(name, return_type, ...) \