Bug 758010 - Wrap operator new/delete to jemalloc on Android. r=jlebar,a=blassey MOBILE140_2012053010_RELBRANCH FENNEC_14_0b5_BUILD1 FENNEC_14_0b5_RELEASE
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 31 May 2012 23:49:03 +0200
branchMOBILE140_2012053010_RELBRANCH
changeset 94448 3dbfe52b2649be8db06cf39ef91c36bf77b77945
parent 94447 fae02854baa34e4fc08952d55623e9a8ca2bbdff
child 94452 9df831053f3a3da00c643fc44824264b9ddff097
push idunknown
push userunknown
push dateunknown
reviewersjlebar, blassey
bugs758010
milestone14.0
Bug 758010 - Wrap operator new/delete to jemalloc on Android. r=jlebar,a=blassey
memory/build/extraMallocFuncs.c
--- a/memory/build/extraMallocFuncs.c
+++ b/memory/build/extraMallocFuncs.c
@@ -2,51 +2,53 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <string.h>
 #include "mozilla/Types.h"
 
 #ifdef ANDROID
 #define wrap(a) __wrap_ ## a
-
-/* operator new wrapper implementation */
-static void *
-new(unsigned int size)
-{
-  return malloc(size);
-}
-/* operator new(unsigned int) */
-MOZ_EXPORT_API(void *)
-wrap(_Znwj)(unsigned int) __attribute__((alias("new")));
-/* operator new[](unsigned int) */
-MOZ_EXPORT_API(void *)
-wrap(_Znaj)(unsigned int) __attribute__((alias("new")));
-
-/* operator delete wrapper implementation */
-static void
-delete(void *ptr)
-{
-  free(ptr);
-}
-/* operator delete(void*) */
-MOZ_EXPORT_API(void)
-wrap(_ZdlPv)(void *ptr) __attribute__((alias("delete")));
-/* operator delete[](void*) */
-MOZ_EXPORT_API(void)
-wrap(_ZdaPv)(void *ptr) __attribute__((alias("delete")));
-#endif
-
-#if defined(XP_WIN) || defined(XP_MACOSX)
+#elif defined(XP_WIN) || defined(XP_MACOSX)
 #define wrap(a) je_ ## a
 #endif
 
 #ifdef wrap
 void *wrap(malloc)(size_t);
+void wrap(free)(void *);
+#endif
 
+#ifdef ANDROID
+/* operator new(unsigned int) */
+MOZ_EXPORT_API(void *)
+wrap(_Znwj)(unsigned int size)
+{
+  return wrap(malloc)(size);
+}
+/* operator new[](unsigned int) */
+MOZ_EXPORT_API(void *)
+wrap(_Znaj)(unsigned int size)
+{
+  return wrap(malloc)(size);
+}
+/* operator delete(void*) */
+MOZ_EXPORT_API(void)
+wrap(_ZdlPv)(void *ptr)
+{
+  wrap(free)(ptr);
+}
+/* operator delete[](void*) */
+MOZ_EXPORT_API(void)
+wrap(_ZdaPv)(void *ptr)
+{
+  wrap(free)(ptr);
+}
+#endif
+
+#ifdef wrap
 MOZ_EXPORT_API(char *)
 wrap(strndup)(const char *src, size_t len)
 {
   char* dst = (char*) wrap(malloc)(len + 1);
   if (dst)
     strncpy(dst, src, len + 1);
   return dst; 
 }