mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 758010 - Wrap operator new/delete to jemalloc on Android. r=jlebar
This commit is contained in:
parent
e3dc2c4f42
commit
0a562bc5d0
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user