michael@0: /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* declarations needed by both nsTraceMalloc.c and nsWinTraceMalloc.cpp */ michael@0: michael@0: #ifndef NSTRACEMALLOCCALLBACKS_H michael@0: #define NSTRACEMALLOCCALLBACKS_H michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: /* Used by backtrace. */ michael@0: typedef struct stack_buffer_info { michael@0: void **buffer; michael@0: size_t size; michael@0: size_t entries; michael@0: } stack_buffer_info; michael@0: michael@0: typedef struct tm_thread tm_thread; michael@0: struct tm_thread { michael@0: /* michael@0: * This counter suppresses tracing, in case any tracing code needs michael@0: * to malloc. michael@0: */ michael@0: uint32_t suppress_tracing; michael@0: michael@0: /* buffer for backtrace, below */ michael@0: stack_buffer_info backtrace_buf; michael@0: }; michael@0: michael@0: /* implemented in nsTraceMalloc.c */ michael@0: tm_thread * tm_get_thread(void); michael@0: michael@0: /* implemented in nsTraceMalloc.c */ michael@0: PR_EXTERN(void) MallocCallback(void *aPtr, size_t aSize, uint32_t start, uint32_t end, tm_thread *t); michael@0: PR_EXTERN(void) CallocCallback(void *aPtr, size_t aCount, size_t aSize, uint32_t start, uint32_t end, tm_thread *t); michael@0: PR_EXTERN(void) ReallocCallback(void *aPin, void* aPout, size_t aSize, uint32_t start, uint32_t end, tm_thread *t); michael@0: PR_EXTERN(void) FreeCallback(void *aPtr, uint32_t start, uint32_t end, tm_thread *t); michael@0: michael@0: #ifdef XP_WIN32 michael@0: /* implemented in nsTraceMalloc.c */ michael@0: PR_EXTERN(void) StartupHooker(); michael@0: PR_EXTERN(void) ShutdownHooker(); michael@0: michael@0: /* implemented in nsWinTraceMalloc.cpp */ michael@0: void* dhw_orig_malloc(size_t); michael@0: void* dhw_orig_calloc(size_t, size_t); michael@0: void* dhw_orig_realloc(void*, size_t); michael@0: void dhw_orig_free(void*); michael@0: michael@0: #endif /* defined(XP_WIN32) */ michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: #endif /* !defined(NSTRACEMALLOCCALLBACKS_H) */