tools/trace-malloc/lib/nsTraceMallocCallbacks.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  *
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 /* declarations needed by both nsTraceMalloc.c and nsWinTraceMalloc.cpp */
     9 #ifndef NSTRACEMALLOCCALLBACKS_H
    10 #define NSTRACEMALLOCCALLBACKS_H
    12 #include <stdint.h>
    13 #include <stdlib.h>
    15 #ifdef __cplusplus
    16 extern "C" {
    17 #endif
    19 /* Used by backtrace. */
    20 typedef struct stack_buffer_info {
    21     void **buffer;
    22     size_t size;
    23     size_t entries;
    24 } stack_buffer_info;
    26 typedef struct tm_thread tm_thread;
    27 struct tm_thread {
    28     /*
    29      * This counter suppresses tracing, in case any tracing code needs
    30      * to malloc.
    31      */
    32     uint32_t suppress_tracing;
    34     /* buffer for backtrace, below */
    35     stack_buffer_info backtrace_buf;
    36 };
    38 /* implemented in nsTraceMalloc.c */
    39 tm_thread * tm_get_thread(void);
    41 /* implemented in nsTraceMalloc.c */
    42 PR_EXTERN(void) MallocCallback(void *aPtr, size_t aSize, uint32_t start, uint32_t end, tm_thread *t);
    43 PR_EXTERN(void) CallocCallback(void *aPtr, size_t aCount, size_t aSize, uint32_t start, uint32_t end, tm_thread *t);
    44 PR_EXTERN(void) ReallocCallback(void *aPin, void* aPout, size_t aSize, uint32_t start, uint32_t end, tm_thread *t);
    45 PR_EXTERN(void) FreeCallback(void *aPtr, uint32_t start, uint32_t end, tm_thread *t);
    47 #ifdef XP_WIN32
    48 /* implemented in nsTraceMalloc.c */
    49 PR_EXTERN(void) StartupHooker();
    50 PR_EXTERN(void) ShutdownHooker();
    52 /* implemented in nsWinTraceMalloc.cpp */
    53 void* dhw_orig_malloc(size_t);
    54 void* dhw_orig_calloc(size_t, size_t);
    55 void* dhw_orig_realloc(void*, size_t);
    56 void dhw_orig_free(void*);
    58 #endif /* defined(XP_WIN32) */
    60 #ifdef __cplusplus
    61 }
    62 #endif
    64 #endif /* !defined(NSTRACEMALLOCCALLBACKS_H) */

mercurial