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

This commit is contained in:
Mike Hommey 2012-05-31 23:49:03 +02:00
parent e3dc2c4f42
commit 0a562bc5d0

View File

@ -7,41 +7,43 @@
#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)
{