Bug 751482 - Move wcsdup and je_dumb_free_thunk out of jemalloc.c. r=jlebar
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 04 May 2012 09:47:00 +0200
changeset 93145 b162f27251fbd43e91c137bbce3529b09c4821f4
parent 93144 9138b968b9e85db92224ac4548591baed917096e
child 93146 5854da577bcb0c85053a210d548770233811aa94
push id22611
push usereakhgari@mozilla.com
push dateFri, 04 May 2012 20:23:57 +0000
treeherdermozilla-central@dc93a3faa54e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs751482
milestone15.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 751482 - Move wcsdup and je_dumb_free_thunk out of jemalloc.c. r=jlebar
memory/build/extraMallocFuncs.c
memory/jemalloc/jemalloc.c
--- a/memory/build/extraMallocFuncs.c
+++ b/memory/build/extraMallocFuncs.c
@@ -26,9 +26,39 @@ wrap(strndup)(const char *src, size_t le
 }
 
 MOZ_EXPORT_API(char *)
 wrap(strdup)(const char *src)
 {
   size_t len = strlen(src);
   return wrap(strndup)(src, len);
 }
+
+#ifdef XP_WIN
+/*
+ *  There's a fun allocator mismatch in (at least) the VS 2010 CRT
+ *  (see the giant comment in this directory's Makefile.in
+ *  that gets redirected here to avoid a crash on shutdown.
+ */
+void
+wrap(dumb_free_thunk)(void *ptr)
+{
+  return; /* shutdown leaks that we don't care about */
+}
+
+#include <wchar.h>
+
+/*
+ *  We also need to provide our own impl of wcsdup so that we don't ask
+ *  the CRT for memory from its heap (which will then be unfreeable).
+ */
+wchar_t *
+wrap(wcsdup)(const wchar_t *src)
+{
+  size_t len = wcslen(src);
+  wchar_t *dst = (wchar_t*) wrap(malloc)((len + 1) * sizeof(wchar_t));
+  if (dst)
+    wcsncpy(dst, src, len + 1);
+  return dst;
+}
+#endif /* XP_WIN */
+
 #endif
--- a/memory/jemalloc/jemalloc.c
+++ b/memory/jemalloc/jemalloc.c
@@ -7152,36 +7152,9 @@ BOOL APIENTRY DllMain(HINSTANCE hModule,
     
     case DLL_PROCESS_DETACH:
       break;
 
   }
 
   return TRUE;
 }
-
-/*
- *  There's a fun allocator mismatch in (at least) the VS 2010 CRT
- *  (see the giant comment in this directory's Makefile.in
- *  that gets redirected here to avoid a crash on shutdown.
- */
-void
-je_dumb_free_thunk(void *ptr)
-{
-  return; /* shutdown leaks that we don't care about */
-}
-
-#include <wchar.h>
-
-/*
- *  We also need to provide our own impl of wcsdup so that we don't ask
- *  the CRT for memory from its heap (which will then be unfreeable).
- */
-wchar_t *je_wcsdup(const wchar_t *src)
-{
-  size_t len = wcslen(src);
-  wchar_t* dst = (wchar_t*)je_malloc((len + 1) * sizeof(wchar_t));
-  if(dst)
-    wcsncpy(dst, src, len + 1);
-  return dst;
-}
-
-#endif
+#endif