Bug 1368932 - Move the replace_malloc_init_funcs function around. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 31 May 2017 13:47:11 +0900
changeset 361711 4753d3677cbe1780928b7b9844700539604c3218
parent 361710 13a1349fb675560c774b9c8157f0e86c37e620e8
child 361712 4bd3eb1b5f3761565871f226e80c4b158defdf48
push id31939
push usercbook@mozilla.com
push dateThu, 01 Jun 2017 11:49:28 +0000
treeherdermozilla-central@d96110d76619 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1368932
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368932 - Move the replace_malloc_init_funcs function around. r=njn
memory/build/replace_malloc.c
--- a/memory/build/replace_malloc.c
+++ b/memory/build/replace_malloc.c
@@ -107,40 +107,17 @@ replace_malloc_handle()
   return true;
 }
 
 #  define REPLACE_MALLOC_GET_FUNC(handle, name) \
     replace_ ## name
 
 #endif
 
-static void
-replace_malloc_init_funcs()
-{
-  replace_malloc_handle_t handle = replace_malloc_handle();
-  if (handle) {
-#ifdef MOZ_NO_REPLACE_FUNC_DECL
-#  define MALLOC_DECL(name, ...) \
-    replace_ ## name = REPLACE_MALLOC_GET_FUNC(handle, name);
-
-#  define MALLOC_FUNCS (MALLOC_FUNCS_INIT | MALLOC_FUNCS_BRIDGE)
-#  include "malloc_decls.h"
-#endif
-
-#define MALLOC_DECL(name, ...) \
-  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"
-}
+static void replace_malloc_init_funcs();
 
 /*
  * Below is the malloc implementation overriding jemalloc and calling the
  * replacement functions if they exist.
  */
 
 static int replace_malloc_initialized = 0;
 static void
@@ -227,8 +204,33 @@ typedef void *(* __realloc_hook_type)(vo
 typedef void *(* __memalign_hook_type)(size_t alignment, size_t size);
 
 MOZ_MEMORY_API __free_hook_type __free_hook = free_impl;
 MOZ_MEMORY_API __malloc_hook_type __malloc_hook = malloc_impl;
 MOZ_MEMORY_API __realloc_hook_type __realloc_hook = realloc_impl;
 MOZ_MEMORY_API __memalign_hook_type __memalign_hook = memalign_impl;
 
 #endif
+
+static void
+replace_malloc_init_funcs()
+{
+  replace_malloc_handle_t handle = replace_malloc_handle();
+  if (handle) {
+#ifdef MOZ_NO_REPLACE_FUNC_DECL
+#  define MALLOC_DECL(name, ...) \
+    replace_ ## name = REPLACE_MALLOC_GET_FUNC(handle, name);
+
+#  define MALLOC_FUNCS (MALLOC_FUNCS_INIT | MALLOC_FUNCS_BRIDGE)
+#  include "malloc_decls.h"
+#endif
+
+#define MALLOC_DECL(name, ...) \
+  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"
+}