Skip to content
Snippets Groups Projects
Commit 79376054 authored by dbaron@dbaron.org's avatar dbaron@dbaron.org
Browse files

Define the __libc_* on Windows to something that does automatic suppression,...

Define the __libc_* on Windows to something that does automatic suppression, like on Linux.  b=391477  r+a=brendan
parent 593cd91c
No related branches found
No related tags found
No related merge requests found
...@@ -97,47 +97,22 @@ extern __ptr_t __libc_valloc(size_t); ...@@ -97,47 +97,22 @@ extern __ptr_t __libc_valloc(size_t);
#pragma GCC visibility pop #pragma GCC visibility pop
#endif #endif
#else /* !XP_UNIX */ #endif /* !XP_UNIX */
#define __libc_malloc(x) malloc(x) #ifdef XP_WIN32
#define __libc_calloc(x, y) calloc(x,y)
#define __libc_realloc(x, y) realloc(x,y)
#define __libc_free(x) free(x)
/* /* defined in nsWinTraceMalloc.cpp */
* Ok we need to load malloc, free, realloc, and calloc from the dll and store void* dhw_orig_malloc(size_t);
* the function pointers somewhere. All other dlls that link with this library void* dhw_orig_calloc(size_t, size_t);
* should have their malloc overridden to call this one. void* dhw_orig_realloc(void*, size_t);
*/ void dhw_orig_free(void*);
typedef void * (__stdcall *MALLOCPROC)(size_t);
typedef void * (__stdcall *REALLOCPROC)(void *, size_t);
typedef void * (__stdcall *CALLOCPROC)(size_t,size_t);
typedef void (__stdcall *FREEPROC)(void *);
/*debug types*/
#ifdef _DEBUG
typedef void * (__stdcall *MALLOCDEBUGPROC) ( size_t, int, const char *, int);
typedef void * (__stdcall *CALLOCDEBUGPROC) ( size_t, size_t, int, const char *, int);
typedef void * (__stdcall *REALLOCDEBUGPROC) ( void *, size_t, int, const char *, int);
typedef void (__stdcall *FREEDEBUGPROC) ( void *, int);
#endif
struct AllocationFuncs #define __libc_malloc(x) dhw_orig_malloc(x)
{ #define __libc_calloc(x, y) dhw_orig_calloc(x,y)
MALLOCPROC malloc_proc; #define __libc_realloc(x, y) dhw_orig_realloc(x,y)
CALLOCPROC calloc_proc; #define __libc_free(x) dhw_orig_free(x)
REALLOCPROC realloc_proc;
FREEPROC free_proc;
#ifdef _DEBUG
MALLOCDEBUGPROC malloc_debug_proc;
CALLOCDEBUGPROC calloc_debug_proc;
REALLOCDEBUGPROC realloc_debug_proc;
FREEDEBUGPROC free_debug_proc;
#endif
int prevent_reentry;
}gAllocFuncs;
#endif /* !XP_UNIX */ #endif
typedef struct logfile logfile; typedef struct logfile logfile;
......
...@@ -148,3 +148,34 @@ PR_IMPLEMENT(void) ...@@ -148,3 +148,34 @@ PR_IMPLEMENT(void)
ShutdownHooker() ShutdownHooker()
{ {
} }
extern "C" {
void* dhw_orig_malloc(size_t);
void* dhw_orig_calloc(size_t, size_t);
void* dhw_orig_realloc(void*, size_t);
void dhw_orig_free(void*);
}
void*
dhw_orig_malloc(size_t size)
{
return DHW_ORIGINAL(MALLOC_, getMallocHooker())(size);
}
void*
dhw_orig_calloc(size_t count, size_t size)
{
return DHW_ORIGINAL(CALLOC_, getCallocHooker())(count,size);
}
void*
dhw_orig_realloc(void* pin, size_t size)
{
return DHW_ORIGINAL(REALLOC_, getReallocHooker())(pin, size);
}
void
dhw_orig_free(void* p)
{
DHW_ORIGINAL(FREE_, getFreeHooker())(p);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment