Thu, 15 Jan 2015 15:59:08 +0100
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.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license |
michael@0 | 5 | * that can be found in the LICENSE file in the root of the source |
michael@0 | 6 | * tree. An additional intellectual property rights grant can be found |
michael@0 | 7 | * in the file PATENTS. All contributing project authors may |
michael@0 | 8 | * be found in the AUTHORS file in the root of the source tree. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | #ifndef __VPX_MEM_H__ |
michael@0 | 13 | #define __VPX_MEM_H__ |
michael@0 | 14 | |
michael@0 | 15 | #include "vpx_config.h" |
michael@0 | 16 | #if defined(__uClinux__) |
michael@0 | 17 | # include <lddk.h> |
michael@0 | 18 | #endif |
michael@0 | 19 | |
michael@0 | 20 | /* vpx_mem version info */ |
michael@0 | 21 | #define vpx_mem_version "2.2.1.5" |
michael@0 | 22 | |
michael@0 | 23 | #define VPX_MEM_VERSION_CHIEF 2 |
michael@0 | 24 | #define VPX_MEM_VERSION_MAJOR 2 |
michael@0 | 25 | #define VPX_MEM_VERSION_MINOR 1 |
michael@0 | 26 | #define VPX_MEM_VERSION_PATCH 5 |
michael@0 | 27 | /* end - vpx_mem version info */ |
michael@0 | 28 | |
michael@0 | 29 | #ifndef VPX_TRACK_MEM_USAGE |
michael@0 | 30 | # define VPX_TRACK_MEM_USAGE 0 /* enable memory tracking/integrity checks */ |
michael@0 | 31 | #endif |
michael@0 | 32 | #ifndef VPX_CHECK_MEM_FUNCTIONS |
michael@0 | 33 | # define VPX_CHECK_MEM_FUNCTIONS 0 /* enable basic safety checks in _memcpy, |
michael@0 | 34 | _memset, and _memmove */ |
michael@0 | 35 | #endif |
michael@0 | 36 | #ifndef REPLACE_BUILTIN_FUNCTIONS |
michael@0 | 37 | # define REPLACE_BUILTIN_FUNCTIONS 0 /* replace builtin functions with their |
michael@0 | 38 | vpx_ equivalents */ |
michael@0 | 39 | #endif |
michael@0 | 40 | |
michael@0 | 41 | #include <stdlib.h> |
michael@0 | 42 | #include <stddef.h> |
michael@0 | 43 | |
michael@0 | 44 | #if defined(__cplusplus) |
michael@0 | 45 | extern "C" { |
michael@0 | 46 | #endif |
michael@0 | 47 | |
michael@0 | 48 | /* |
michael@0 | 49 | vpx_mem_get_version() |
michael@0 | 50 | provided for runtime version checking. Returns an unsigned int of the form |
michael@0 | 51 | CHIEF | MAJOR | MINOR | PATCH, where the chief version number is the high |
michael@0 | 52 | order byte. |
michael@0 | 53 | */ |
michael@0 | 54 | unsigned int vpx_mem_get_version(void); |
michael@0 | 55 | |
michael@0 | 56 | /* |
michael@0 | 57 | vpx_mem_set_heap_size(size_t size) |
michael@0 | 58 | size - size in bytes for the memory manager to allocate for its heap |
michael@0 | 59 | Sets the memory manager's initial heap size |
michael@0 | 60 | Return: |
michael@0 | 61 | 0: on success |
michael@0 | 62 | -1: if memory manager calls have not been included in the vpx_mem lib |
michael@0 | 63 | -2: if the memory manager has been compiled to use static memory |
michael@0 | 64 | -3: if the memory manager has already allocated its heap |
michael@0 | 65 | */ |
michael@0 | 66 | int vpx_mem_set_heap_size(size_t size); |
michael@0 | 67 | |
michael@0 | 68 | void *vpx_memalign(size_t align, size_t size); |
michael@0 | 69 | void *vpx_malloc(size_t size); |
michael@0 | 70 | void *vpx_calloc(size_t num, size_t size); |
michael@0 | 71 | void *vpx_realloc(void *memblk, size_t size); |
michael@0 | 72 | void vpx_free(void *memblk); |
michael@0 | 73 | |
michael@0 | 74 | void *vpx_memcpy(void *dest, const void *src, size_t length); |
michael@0 | 75 | void *vpx_memset(void *dest, int val, size_t length); |
michael@0 | 76 | void *vpx_memmove(void *dest, const void *src, size_t count); |
michael@0 | 77 | |
michael@0 | 78 | /* special memory functions */ |
michael@0 | 79 | void *vpx_mem_alloc(int id, size_t size, size_t align); |
michael@0 | 80 | void vpx_mem_free(int id, void *mem, size_t size); |
michael@0 | 81 | |
michael@0 | 82 | /* Wrappers to standard library functions. */ |
michael@0 | 83 | typedef void *(* g_malloc_func)(size_t); |
michael@0 | 84 | typedef void *(* g_calloc_func)(size_t, size_t); |
michael@0 | 85 | typedef void *(* g_realloc_func)(void *, size_t); |
michael@0 | 86 | typedef void (* g_free_func)(void *); |
michael@0 | 87 | typedef void *(* g_memcpy_func)(void *, const void *, size_t); |
michael@0 | 88 | typedef void *(* g_memset_func)(void *, int, size_t); |
michael@0 | 89 | typedef void *(* g_memmove_func)(void *, const void *, size_t); |
michael@0 | 90 | |
michael@0 | 91 | int vpx_mem_set_functions(g_malloc_func g_malloc_l |
michael@0 | 92 | , g_calloc_func g_calloc_l |
michael@0 | 93 | , g_realloc_func g_realloc_l |
michael@0 | 94 | , g_free_func g_free_l |
michael@0 | 95 | , g_memcpy_func g_memcpy_l |
michael@0 | 96 | , g_memset_func g_memset_l |
michael@0 | 97 | , g_memmove_func g_memmove_l); |
michael@0 | 98 | int vpx_mem_unset_functions(void); |
michael@0 | 99 | |
michael@0 | 100 | |
michael@0 | 101 | /* some defines for backward compatibility */ |
michael@0 | 102 | #define DMEM_GENERAL 0 |
michael@0 | 103 | |
michael@0 | 104 | // (*)< |
michael@0 | 105 | |
michael@0 | 106 | #if REPLACE_BUILTIN_FUNCTIONS |
michael@0 | 107 | # ifndef __VPX_MEM_C__ |
michael@0 | 108 | # define memalign vpx_memalign |
michael@0 | 109 | # define malloc vpx_malloc |
michael@0 | 110 | # define calloc vpx_calloc |
michael@0 | 111 | # define realloc vpx_realloc |
michael@0 | 112 | # define free vpx_free |
michael@0 | 113 | # define memcpy vpx_memcpy |
michael@0 | 114 | # define memmove vpx_memmove |
michael@0 | 115 | # define memset vpx_memset |
michael@0 | 116 | # endif |
michael@0 | 117 | #endif |
michael@0 | 118 | |
michael@0 | 119 | #if CONFIG_MEM_TRACKER |
michael@0 | 120 | #include <stdarg.h> |
michael@0 | 121 | /*from vpx_mem/vpx_mem_tracker.c*/ |
michael@0 | 122 | extern void vpx_memory_tracker_dump(); |
michael@0 | 123 | extern void vpx_memory_tracker_check_integrity(char *file, unsigned int line); |
michael@0 | 124 | extern int vpx_memory_tracker_set_log_type(int type, char *option); |
michael@0 | 125 | extern int vpx_memory_tracker_set_log_func(void *userdata, |
michael@0 | 126 | void(*logfunc)(void *userdata, |
michael@0 | 127 | const char *fmt, va_list args)); |
michael@0 | 128 | # ifndef __VPX_MEM_C__ |
michael@0 | 129 | # define vpx_memalign(align, size) xvpx_memalign((align), (size), __FILE__, __LINE__) |
michael@0 | 130 | # define vpx_malloc(size) xvpx_malloc((size), __FILE__, __LINE__) |
michael@0 | 131 | # define vpx_calloc(num, size) xvpx_calloc(num, size, __FILE__, __LINE__) |
michael@0 | 132 | # define vpx_realloc(addr, size) xvpx_realloc(addr, size, __FILE__, __LINE__) |
michael@0 | 133 | # define vpx_free(addr) xvpx_free(addr, __FILE__, __LINE__) |
michael@0 | 134 | # define vpx_memory_tracker_check_integrity() vpx_memory_tracker_check_integrity(__FILE__, __LINE__) |
michael@0 | 135 | # define vpx_mem_alloc(id,size,align) xvpx_mem_alloc(id, size, align, __FILE__, __LINE__) |
michael@0 | 136 | # define vpx_mem_free(id,mem,size) xvpx_mem_free(id, mem, size, __FILE__, __LINE__) |
michael@0 | 137 | # endif |
michael@0 | 138 | |
michael@0 | 139 | void *xvpx_memalign(size_t align, size_t size, char *file, int line); |
michael@0 | 140 | void *xvpx_malloc(size_t size, char *file, int line); |
michael@0 | 141 | void *xvpx_calloc(size_t num, size_t size, char *file, int line); |
michael@0 | 142 | void *xvpx_realloc(void *memblk, size_t size, char *file, int line); |
michael@0 | 143 | void xvpx_free(void *memblk, char *file, int line); |
michael@0 | 144 | void *xvpx_mem_alloc(int id, size_t size, size_t align, char *file, int line); |
michael@0 | 145 | void xvpx_mem_free(int id, void *mem, size_t size, char *file, int line); |
michael@0 | 146 | |
michael@0 | 147 | #else |
michael@0 | 148 | # ifndef __VPX_MEM_C__ |
michael@0 | 149 | # define vpx_memory_tracker_dump() |
michael@0 | 150 | # define vpx_memory_tracker_check_integrity() |
michael@0 | 151 | # define vpx_memory_tracker_set_log_type(t,o) 0 |
michael@0 | 152 | # define vpx_memory_tracker_set_log_func(u,f) 0 |
michael@0 | 153 | # endif |
michael@0 | 154 | #endif |
michael@0 | 155 | |
michael@0 | 156 | #if !VPX_CHECK_MEM_FUNCTIONS |
michael@0 | 157 | # ifndef __VPX_MEM_C__ |
michael@0 | 158 | # include <string.h> |
michael@0 | 159 | # define vpx_memcpy memcpy |
michael@0 | 160 | # define vpx_memset memset |
michael@0 | 161 | # define vpx_memmove memmove |
michael@0 | 162 | # endif |
michael@0 | 163 | #endif |
michael@0 | 164 | |
michael@0 | 165 | #ifdef VPX_MEM_PLTFRM |
michael@0 | 166 | # include VPX_MEM_PLTFRM |
michael@0 | 167 | #endif |
michael@0 | 168 | |
michael@0 | 169 | #if defined(__cplusplus) |
michael@0 | 170 | } |
michael@0 | 171 | #endif |
michael@0 | 172 | |
michael@0 | 173 | #endif /* __VPX_MEM_H__ */ |