Permalink
Browse files

Bug 758010 - Wrap operator new/delete to jemalloc on Android. r=jleba…

…r,a=blassey

--HG--
branch : MOBILE140_2012053010_RELBRANCH
  • Loading branch information...
1 parent e2a209c commit 8b77f406e5a10159146a2fcacf41ac864357c140 @glandium glandium committed May 31, 2012
Showing with 23 additions and 21 deletions.
  1. +23 −21 memory/build/extraMallocFuncs.c
@@ -7,41 +7,43 @@
#ifdef ANDROID
#define wrap(a) __wrap_ ## a
+#elif defined(XP_WIN) || defined(XP_MACOSX)
+#define wrap(a) je_ ## a
+#endif
-/* operator new wrapper implementation */
-static void *
-new(unsigned int size)
-{
- return malloc(size);
-}
+#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) __attribute__((alias("new")));
+wrap(_Znwj)(unsigned int size)
+{
+ return wrap(malloc)(size);
+}
/* operator new[](unsigned int) */
MOZ_EXPORT_API(void *)
-wrap(_Znaj)(unsigned int) __attribute__((alias("new")));
-
-/* operator delete wrapper implementation */
-static void
-delete(void *ptr)
+wrap(_Znaj)(unsigned int size)
{
- free(ptr);
+ return wrap(malloc)(size);
}
/* operator delete(void*) */
MOZ_EXPORT_API(void)
-wrap(_ZdlPv)(void *ptr) __attribute__((alias("delete")));
+wrap(_ZdlPv)(void *ptr)
+{
+ wrap(free)(ptr);
+}
/* operator delete[](void*) */
MOZ_EXPORT_API(void)
-wrap(_ZdaPv)(void *ptr) __attribute__((alias("delete")));
-#endif
-
-#if defined(XP_WIN) || defined(XP_MACOSX)
-#define wrap(a) je_ ## a
+wrap(_ZdaPv)(void *ptr)
+{
+ wrap(free)(ptr);
+}
#endif
#ifdef wrap
-void *wrap(malloc)(size_t);
-
MOZ_EXPORT_API(char *)
wrap(strndup)(const char *src, size_t len)
{

0 comments on commit 8b77f40

Please sign in to comment.