Changeset ba6f0c in git
- Timestamp:
- Nov 26, 1999, 6:57:54 PM (24 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- 1cbba61f1dd6a40e718cf26b45cf9ec15a0f849f
- Parents:
- a89a22ce7744ac91b8406062c921c8beb8c652a0
- Location:
- omalloc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
omalloc/omAlloc.c
ra89a22c rba6f0c 4 4 * Author: obachman@mathematik.uni-kl.de (Olaf Bachmann) 5 5 * Created: 11/99 6 * Version: $Id: omAlloc.c,v 1. 3 1999-11-23 20:40:12obachman Exp $6 * Version: $Id: omAlloc.c,v 1.4 1999-11-26 17:57:51 obachman Exp $ 7 7 *******************************************************************/ 8 8 #ifndef OM_ALLOC_C … … 70 70 { 71 71 void* new_addr; 72 int _ _om_fill = new_size - old_size;72 int _om_fill = new_size - old_size; 73 73 new_addr = _omReallocBlock(void*, new_addr, new_size, old_addr, old_size); 74 if (_om_fill > 0) memset( ((void*) new_addr) + __om_fill, 0, __om_fill);74 if (_om_fill > 0) memset(new_addr + _om_fill, 0, _om_fill); 75 75 return new_addr; 76 76 } … … 111 111 { 112 112 void* new_addr; 113 int __om_fill = new_size - old_size;113 int om_fill = new_size - old_size; 114 114 __omTypeReallocAlignedBlock(void*, new_addr, new_size, old_addr, old_size); 115 if ( _om_fill > 0) memset(((void*) new_addr) + __om_fill, 0, __om_fill);115 if (om_fill > 0) memset(new_addr + om_fill, 0, om_fill); 116 116 return new_addr; 117 117 } … … 226 226 #endif /* OM_ALIGNMENT_NEEDS_WORK */ 227 227 228 /******************************************************************* 229 * 230 * Definition of Func 231 * 232 *******************************************************************/ 233 234 #define ALLOCBIN_FUNC_WRAPPER(func) \ 235 void* omFunc##func (omBin bin) \ 236 { \ 237 void* addr; \ 238 __omType##func (void*, addr, bin); \ 239 return addr; \ 240 } 241 242 #define ALLOCSIZE_FUNC_WRAPPER(func) \ 243 void* omFunc##func (size_t size) \ 244 { \ 245 void* addr; \ 246 __omType##func (void*, addr, size); \ 247 return addr; \ 248 } 249 250 #define FREE_FUNC_WRAPPER(func) \ 251 void omFunc##func (void* addr) \ 252 { \ 253 __om##func (addr); \ 254 } 255 256 #define FREEBLOCK_FUNC_WRAPPER(func) \ 257 void omFunc##func (void* addr, size_t size) \ 258 { \ 259 __om##func (addr, size); \ 260 } 261 262 ALLOCBIN_FUNC_WRAPPER(AllocBin) 263 ALLOCBIN_FUNC_WRAPPER(Alloc0Bin) 264 FREE_FUNC_WRAPPER(FreeBin) 265 ALLOCSIZE_FUNC_WRAPPER(AllocBlock) 266 ALLOCSIZE_FUNC_WRAPPER(Alloc0Block) 267 FREEBLOCK_FUNC_WRAPPER(FreeBlock) 268 ALLOCSIZE_FUNC_WRAPPER(AllocChunk) 269 ALLOCSIZE_FUNC_WRAPPER(Alloc0Chunk) 270 FREE_FUNC_WRAPPER(FreeChunk) 271 272 #ifdef OM_ALIGNMENT_NEEDS_WORK 273 ALLOCSIZE_FUNC_WRAPPER(AllocAlignedBlock) 274 ALLOCSIZE_FUNC_WRAPPER(Alloc0AlignedBlock) 275 ALLOCSIZE_FUNC_WRAPPER(AllocAlignedChunk) 276 ALLOCSIZE_FUNC_WRAPPER(Alloc0AlignedChunk) 277 FREE_FUNC_WRAPPER(FreeAlignedChunk) 278 #endif 228 279 229 280 /******************************************************************* -
omalloc/omAlloc.h
ra89a22c rba6f0c 4 4 * Author: obachman@mathematik.uni-kl.de (Olaf Bachmann) 5 5 * Created: 11/99 6 * Version: $Id: omAlloc.h,v 1. 1.1.1 1999-11-18 17:45:52 obachman Exp $6 * Version: $Id: omAlloc.h,v 1.2 1999-11-26 17:57:52 obachman Exp $ 7 7 *******************************************************************/ 8 8 #ifndef OM_ALLOC_H 9 9 #define OM_ALLOC_H 10 10 11 /******************************************************************* 12 * 13 * Alloc/Free 14 * 15 *******************************************************************/ 16 17 void* omFuncAlloc(size_t size); 18 void* omFuncAlloc0(size_t size); 19 void* omFuncAlloc(size_t size); 20 void* omFuncAlloc0(size_t size); 21 void omFuncFree(void* addr); 22 23 void* omFuncAllocBlock(size_t size); 24 void* omFuncAlloc0Block(size_t size); 25 void omFuncFreeBlock(void* addr, size_t size); 26 27 void* omFuncAllocHeap(omHeap heap); 28 void* omFuncAlloc0Heap(omHeap heap); 29 void omFuncFreeHeap(void* addr); 30 31 32 #ifndef OM_DEBUG 33 34 #define omAlloc(size) _omAlloc(size) 35 #define omAlloc0(size) _omAlloc0(size) 36 #define omAllocAligned(size) _omAllocAligned(size) 37 #define omTypeAlloc(size) _omTypeAlloc(addr, type, size) 38 #define omTypeAlloc0(size) _omTypeAlloc0(addr, type, size) 39 #define omTypeAllocAligned(size) _omTypeAllocAligned(addr, type, size) 40 #define omFree(addr) _omFree(addr) 41 42 #define omAllocBlock(size) _omAllocBlock(size) 43 #define omAlloc0Block(size) _omAlloc0Block(size) 44 #define omAllocAlignedBlock(size) _omAllocAlignedBlock(size) 45 #define omTypeAllocBlock(size) _omTypeAllocBlock(addr, type, size) 46 #define omTypeAlloc0Block(size) _omTypeAlloc0Block(addr, type, size) 47 #define omTypeAllocAlignedBlock(size) _omTypeAllocAlignedBlock(addr, type, size) 48 #define omFreeBlock(addr, size) _omFreeBlock(addr, size) 49 50 #define omAllocHeap(heap) _omAllocHeap(heap) 51 #define omAlloc0Heap(heap) _omAlloc0Heap(heap) 52 #define omAllocAlignedHeap(heap) _omAllocAligned(heap) 53 #define omTypeAllocHeap(size) _omTypeAllocHeap(addr, type, size) 54 #define omTypeAlloc0Heap(size) _omTypeAlloc0Heap(addr, type, size) 55 #define omTypeAllocAlignedHeap(size) _omTypeAllocAlignedHeap(addr, type, size) 56 #define omFreeHeap(addr) _omFreeHeap(addr) 57 58 #define omDebugAlloc(size, fn, l) _omAlloc(size) 59 #define omDebugAlloc0(size, fn, l) _omAlloc0(size) 60 #define omDebugAllocAligned(size, fn, l) _omAllocAligned(size) 61 #define omDebugTypeAlloc(size, fn, l) _omTypeAlloc(addr, type, size) 62 #define omDebugTypeAlloc0(size, fn, l) _omTypeAlloc0(addr, type, size) 63 #define omDebugTypeAllocAligned(size, fn, l) _omTypeAllocAligned(addr, type, size) 64 #define omDebugFree(addr, fn, l) _omFree(addr) 65 66 #define omDebugAllocBlock(size, fn, l) _omAllocBlock(size) 67 #define omDebugAlloc0Block(size, fn, l) _omAlloc0Block(size) 68 #define omDebugAllocAlignedBlock(size, fn, l) _omAllocAlignedBlock(size) 69 #define omDebugTypeAllocBlock(size, fn, l) _omTypeAllocBlock(addr, type, size) 70 #define omDebugTypeAlloc0Block(size, fn, l) _omTypeAlloc0Block(addr, type, size) 71 #define omDebugTypeAllocAlignedBlock(size, fn, l) _omTypeAllocAlignedBlock(addr, type, size) 72 #define omDebugFreeBlock(addr, size, fn, l) _omFreeBlock(addr, size) 73 74 #define omDebugAllocHeap(heap, fn, l) _omAllocHeap(heap) 75 #define omDebugAlloc0Heap(heap, fn, l) _omAlloc0Heap(heap) 76 #define omDebugAllocAlignedHeap(heap, fn, l) _omAllocAligned(heap) 77 #define omDebugTypeAllocHeap(size, fn, l) _omTypeAllocHeap(addr, type, size) 78 #define omDebugTypeAlloc0Heap(size, fn, l) _omTypeAlloc0Heap(addr, type, size) 79 #define omDebugTypeAllocAlignedHeap(size, fn, l) _omTypeAllocAlignedHeap(addr, type, size) 80 #define omDebugFreeHeap(addr, fn, l) _omFreeHeap(addr) 81 82 83 #define omTrackAlloc(size) _omAlloc(size) 84 #define omTrackAlloc0(size) _omAlloc0(size) 85 #define omTrackAllocAligned(size) _omAllocAligned(size) 86 #define omTypeTrackAlloc(size) _omTypeAlloc(addr, type, size) 87 #define omTypeTrackAlloc0(size) _omTypeAlloc0(addr, type, size) 88 #define omTypeTrackAllocAligned(size) _omTypeAllocAligned(addr, type, size) 89 #define omTrackFree(addr) _omFree(addr) 90 91 #define omTrackAllocBlock(size) _omAllocBlock(size) 92 #define omTrackAlloc0Block(size) _omAlloc0Block(size) 93 #define omTrackAllocAlignedBlock(size) _omAllocAlignedBlock(size) 94 #define omTypeTrackAllocBlock(size) _omTypeAllocBlock(addr, type, size) 95 #define omTypeTrackAlloc0Block(size) _omTypeAlloc0Block(addr, type, size) 96 #define omTypeTrackAllocAlignedBlock(size) _omTypeAllocAlignedBlock(addr, type, size) 97 #define omTrackFreeBlock(addr, size) _omFreeBlock(addr, size) 98 99 #define omTrackAllocHeap(heap) _omAllocHeap(heap) 100 #define omTrackAlloc0Heap(heap) _omAlloc0Heap(heap) 101 #define omTrackAllocAlignedHeap(heap) _omAllocAligned(heap) 102 #define omTypeTrackAllocHeap(size) _omTypeAllocHeap(addr, type, size) 103 #define omTypeTrackAlloc0Heap(size) _omTypeAlloc0Heap(addr, type, size) 104 #define omTypeTrackAllocAlignedHeap(size) _omTypeAllocAlignedHeap(addr, type, size) 105 #define omTrackFreeHeap(addr) _omFreeHeap(addr) 106 107 #define omDebugTrackAlloc(size, fn, l) _omAlloc(size) 108 #define omDebugTrackAlloc0(size, fn, l) _omAlloc0(size) 109 #define omDebugTrackAllocAligned(size, fn, l) _omAllocAligned(size) 110 #define omDebugTypeTrackAlloc(size, fn, l) _omTypeAlloc(addr, type, size) 111 #define omDebugTypeTrackAlloc0(size, fn, l) _omTypeAlloc0(addr, type, size) 112 #define omDebugTypeTrackAllocAligned(size, fn, l) _omTypeAllocAligned(addr, type, size) 113 #define omDebugTrackFree(addr, fn, l) _omFree(addr) 114 115 #define omDebugTrackAllocBlock(size, fn, l) _omAllocBlock(size) 116 #define omDebugTrackAlloc0Block(size, fn, l) _omAlloc0Block(size) 117 #define omDebugTrackAllocAlignedBlock(size, fn, l) _omAllocAlignedBlock(size) 118 #define omDebugTypeTrackAllocBlock(size, fn, l) _omTypeAllocBlock(addr, type, size) 119 #define omDebugTypeTrackAlloc0Block(size, fn, l) _omTypeAlloc0Block(addr, type, size) 120 #define omDebugTypeTrackAllocAlignedBlock(size, fn, l) _omTypeAllocAlignedBlock(addr, type, size) 121 #define omDebugTrackFreeBlock(addr, size, fn, l) _omFreeBlock(addr, size) 122 123 #define omDebugTrackAllocHeap(heap, fn, l) _omAllocHeap(heap) 124 #define omDebugTrackAlloc0Heap(heap, fn, l) _omAlloc0Heap(heap) 125 #define omDebugTrackAllocAlignedHeap(heap, fn, l) _omAllocAligned(heap) 126 #define omDebugTypeTrackAllocHeap(size, fn, l) _omTypeAllocHeap(addr, type, size) 127 #define omDebugTypeTrackAlloc0Heap(size, fn, l) _omTypeAlloc0Heap(addr, type, size) 128 #define omDebugTypeTrackAllocAlignedHeap(size, fn, l) _omTypeAllocAlignedHeap(addr, type, size) 129 #define omDebugTrackFreeHeap(addr, fn, l) _omFreeHeap(addr) 130 131 #else 132 133 #define omAlloc(size) omDebugAlloc(size, __FILE__, __LINE__) 134 #define omAlloc0(size) omDebugAlloc0(size, __FILE__, __LINE__) 135 #define omAllocAligned(size) omDebugAllocAligned(size, __FILE__, __LINE__) 136 #define omTypeAlloc(size) omDebugTypeAlloc(addr, type, size, __FILE__, __LINE__) 137 #define omTypeAlloc0(size) omDebugTypeAlloc0(addr, type, size, __FILE__, __LINE__) 138 #define omTypeAllocAligned(size) omDebugTypeAllocAligned(addr, type, size, __FILE__, __LINE__) 139 #define omFree(addr) omDebugFree(addr, __FILE__, __LINE__) 140 141 #define omAllocBlock(size) omDebugAllocBlock(size, __FILE__, __LINE__) 142 #define omAlloc0Block(size) omDebugAlloc0Block(size, __FILE__, __LINE__) 143 #define omAllocAlignedBlock(size) omDebugAllocAlignedBlock(size, __FILE__, __LINE__) 144 #define omTypeAllocBlock(size) omDebugTypeAllocBlock(addr, type, size, __FILE__, __LINE__) 145 #define omTypeAlloc0Block(size) omDebugTypeAlloc0Block(addr, type, size, __FILE__, __LINE__) 146 #define omTypeAllocAlignedBlock(size) omDebugTypeAllocAlignedBlock(addr, type, size, __FILE__, __LINE__) 147 #define omFreeBlock(addr, size) omDebugFreeBlock(addr, size, __FILE__, __LINE__) 148 149 #define omAllocHeap(heap) omDebugAllocHeap(heap, __FILE__, __LINE__) 150 #define omAlloc0Heap(heap) omDebugAlloc0Heap(heap, __FILE__, __LINE__) 151 #define omAllocAlignedHeap(heap) omDebugAllocAligned(heap, __FILE__, __LINE__) 152 #define omTypeAllocHeap(size) omDebugTypeAllocHeap(addr, type, size, __FILE__, __LINE__) 153 #define omTypeAlloc0Heap(size) omDebugTypeAlloc0Heap(addr, type, size, __FILE__, __LINE__) 154 #define omTypeAllocAlignedHeap(size) omDebugTypeAllocAlignedHeap(addr, type, size, __FILE__, __LINE__) 155 #define omFreeHeap(addr) omDebugFreeHeap(addr, __FILE__, __LINE__) 156 157 #define omTrackAlloc(size) omDebugTrackAlloc(size, __FILE__, __LINE__) 158 #define omTrackAlloc0(size) omDebugTrackAlloc0(size, __FILE__, __LINE__) 159 #define omTrackAllocAligned(size) omDebugTrackAllocAligned(size, __FILE__, __LINE__) 160 #define omTypeTrackAlloc(size) omDebugTypeTrackAlloc(addr, type, size, __FILE__, __LINE__) 161 #define omTypeTrackAlloc0(size) omDebugTypeTrackAlloc0(addr, type, size, __FILE__, __LINE__) 162 #define omTypeTrackAllocAligned(size) omDebugTypeTrackAllocAligned(addr, type, size, __FILE__, __LINE__) 163 #define omTrackFree(addr) omDebugFree(addr, __FILE__, __LINE__) 164 165 #define omTrackAllocBlock(size) omDebugTrackAllocBlock(size, __FILE__, __LINE__) 166 #define omTrackAlloc0Block(size) omDebugTrackAlloc0Block(size, __FILE__, __LINE__) 167 #define omTrackAllocAlignedBlock(size) omDebugTrackAllocAlignedBlock(size, __FILE__, __LINE__) 168 #define omTypeTrackAllocBlock(size) omDebugTypeTrackAllocBlock(addr, type, size, __FILE__, __LINE__) 169 #define omTypeTrackAlloc0Block(size) omDebugTypeTrackAlloc0Block(addr, type, size, __FILE__, __LINE__) 170 #define omTypeTrackAllocAlignedBlock(size) omDebugTypeTrackAllocAlignedBlock(addr, type, size, __FILE__, __LINE__) 171 #define omTrackFreeBlock(addr, size) omDebugFreeBlock(addr, size, __FILE__, __LINE__) 172 173 #define omTrackAllocHeap(heap) omDebugTrackAllocHeap(heap, __FILE__, __LINE__) 174 #define omTrackAlloc0Heap(heap) omDebugTrackAlloc0Heap(heap, __FILE__, __LINE__) 175 #define omTrackAllocAlignedHeap(heap) omDebugTrackAllocAligned(heap, __FILE__, __LINE__) 176 #define omTypeTrackAllocHeap(size) omDebugTypeTrackAllocHeap(addr, type, size, __FILE__, __LINE__) 177 #define omTypeTrackAlloc0Heap(size) omDebugTypeTrackAlloc0Heap(addr, type, size, __FILE__, __LINE__) 178 #define omTypeTrackAllocAlignedHeap(size) omDebugTypeTrackAllocAlignedHeap(addr, type, size, __FILE__, __LINE__) 179 #define omTrackFreeHeap(addr) omDebugFreeHeap(addr, __FILE__, __LINE__) 180 181 182 #endif /* OM_DEBUG */ 183 184 #ifdef HAVE_CONFIG_H 185 #include "omConfig.h" 186 #endif 187 188 #include "omPrivate.h" 11 #ifndef OM_USE_EXTERNAL_MALLOC 12 /******************************************************************* 13 * forward type declarations 14 *******************************************************************/ 15 struct omBin_s; 16 struct omSpecBin_s; 17 typedef struct omBin_s omBin_t; 18 typedef struct omSpecBin_s omSpecBin_t; 19 typedef omBin_t* omBin; 20 typedef omSpecBin_t* omSpecBin; 21 22 /******************************************************************* 23 * 24 * Alloc/Free Func 25 * 26 *******************************************************************/ 27 extern void* omFuncAllocBin(omBin bin); 28 extern void* omFuncAlloc0Bin(omBin bin); 29 extern void omFuncFreeBin(void* addr); 30 extern void omFuncPseudoFreeBin(void* addr); 31 32 extern void* omFuncAllocBlock(size_t size); 33 extern void* omFuncAlloc0Block(size_t size); 34 extern void* omFuncReallocBlock(void* addr, size_t old_size, size_t new_size); 35 extern void* omFuncReallo0cBlock(void* addr, size_t old_size, size_t new_size); 36 extern void* omFuncAllocAlignedBlock(size_t size); 37 extern void* omFuncAlloc0AlignedBlock(size_t size); 38 extern void* omFuncReallocAlignedBlock(void* addr,size_t old_size,size_t new_size); 39 extern void* omFuncRealloc0AlignedBlock(void* addr,size_t old_size,size_t new_size); 40 extern void omFuncFreeBlock(void* addr, size_t size); 41 extern void* omFuncPseudoReallocBlock(void* addr, size_t old_size, size_t new_size); 42 extern void* omFuncPseudoReallo0cBlock(void* addr, size_t old_size, size_t new_size); 43 extern void* omFuncPseudoReallocAlignedBlock(void* addr,size_t old_size,size_t new_size); 44 extern void* omFuncPseudoRealloc0AlignedBlock(void* addr,size_t old_size,size_t new_size); 45 extern void omFuncPseudoFreeBlock(void* addr, size_t size); 46 47 extern void* omFuncAllocChunk(size_t size); 48 extern void* omFuncAlloc0Chunk(size_t size); 49 extern void* omFuncAllocAlignedChunk(size_t size); 50 extern void* omFuncAlloc0AlignedChunk(size_t size); 51 extern void* omFuncReallocChunk(void* addr, size_t size); 52 extern void* omFuncReallocAlignedChunk(void* addr, size_t size); 53 extern void omFuncFreeChunk(void* addr); 54 extern void omFuncFreeAlignedChunk(void* addr); 55 extern void* omFuncPseudoReallocChunk(void* addr, size_t size); 56 extern void* omFuncPseudoReallocAlignedChunk(void* addr, size_t size); 57 extern void omFuncPseudoFreeChunk(void* addr); 58 extern void omFuncPseudoFreeAlignedChunk(void* addr); 59 60 /******************************************************************* 61 * 62 * Alloc/Free Check 63 * 64 *******************************************************************/ 65 extern void* omCheckAllocBin(omBin bin, int level); 66 extern void* omCheckAlloc0Bin(omBin bin, int level); 67 extern void omCheckFreeBin(void* addr, int level); 68 extern void omCheckPseudoFreeBin(void* addr, int level); 69 70 extern void* omCheckAllocBlock(size_t size, int level); 71 extern void* omCheckAlloc0Block(size_t size, int level); 72 extern void* omCheckReallocBlock(void* addr, size_t old_size, size_t new_size, int level); 73 extern void* omCheckReallo0cBlock(void* addr, size_t old_size, size_t new_size, int level); 74 extern void* omCheckAllocAlignedBlock(size_t size, int level); 75 extern void* omCheckAlloc0AlignedBlock(size_t size, int level); 76 extern void* omCheckReallocAlignedBlock(void* addr,size_t old_size,size_t new_size, int level); 77 extern void* omCheckRealloc0AlignedBlock(void* addr,size_t old_size,size_t new_size, int level); 78 extern void omCheckFreeBlock(void* addr, size_t size, int level); 79 extern void* omCheckPseudoReallocBlock(void* addr, size_t old_size, size_t new_size, int level); 80 extern void* omCheckPseudoReallo0cBlock(void* addr, size_t old_size, size_t new_size, int level); 81 extern void* omCheckPseudoReallocAlignedBlock(void* addr,size_t old_size,size_t new_size, int level); 82 extern void* omCheckPseudoRealloc0AlignedBlock(void* addr,size_t old_size,size_t new_size, int level); 83 extern void omCheckPseudoFreeBlock(void* addr, size_t size, int level); 84 85 extern void* omCheckAllocChunk(size_t size, int level); 86 extern void* omCheckAlloc0Chunk(size_t size, int level); 87 extern void* omCheckAllocAlignedChunk(size_t size, int level); 88 extern void* omCheckAlloc0AlignedChunk(size_t size, int level); 89 extern void* omCheckReallocChunk(void* addr, size_t size, int level); 90 extern void* omCheckReallocAlignedChunk(void* addr, size_t size, int level); 91 extern void omCheckFreeChunk(void* addr, int level); 92 extern void omCheckFreeAlignedChunk(void* addr, int level); 93 extern void* omCheckPseudoReallocChunk(void* addr, size_t size, int level); 94 extern void* omCheckPseudoReallocAlignedChunk(void* addr, size_t size, int level); 95 extern void omCheckPseudoFreeChunk(void* addr, int level); 96 extern void omCheckPseudoFreeAlignedChunk(void* addr, int level); 97 98 /* Check of addr/bins -- return NULL if ok, error message, otherwise */ 99 extern char* omCheckBinAddr(void* addr, int level); 100 extern char* omCheckBin(omBin bin, int level); 101 extern char* omCheckAllBins(int level); 102 extern char* omCheckBlockAddr(void* addr, size_t size, int level); 103 extern char* omCheckAlignedBlockAddr(void* addr, size_t size, int level); 104 extern char* omCheckChunkAddr(void* addr); 105 extern char* omCheckAlignedChunkAddr(void* addr); 106 107 /* CheckReport of addr/bins -- return 1 if ok, otherwise print error and backtrace to stdout 108 and return 0 */ 109 extern int omCheckReportBinAddr(void* addr, int level); 110 extern int omCheckReportBin(omBin bin, int level); 111 extern int omCheckReportAllBins(int level); 112 extern int omCheckReportBlockAddr(void* addr, size_t size, int level); 113 extern int omCheckReportAlignedBlockAddr(void* addr, size_t size, int level); 114 extern int omCheckReportChunkAddr(void* addr); 115 extern int omCheckReportAlignedChunkAddr(void* addr); 116 117 /******************************************************************* 118 * 119 * Alloc/Free Debug 120 * 121 *******************************************************************/ 122 extern void* omDebugAllocBin(omBin bin, int level); 123 extern void* omDebugAlloc0Bin(omBin bin, int level); 124 extern void omDebugFreeBin(void* addr, int level); 125 extern void omDebugPseudoFreeBin(void* addr, int level); 126 127 extern void* omDebugAllocBlock(size_t size, int level); 128 extern void* omDebugAlloc0Block(size_t size, int level); 129 extern void* omDebugReallocBlock(void* addr, size_t old_size, size_t new_size, int level); 130 extern void* omDebugReallo0cBlock(void* addr, size_t old_size, size_t new_size, int level); 131 extern void* omDebugAllocAlignedBlock(size_t size, int level); 132 extern void* omDebugAlloc0AlignedBlock(size_t size, int level); 133 extern void* omDebugReallocAlignedBlock(void* addr,size_t old_size,size_t new_size, int level); 134 extern void* omDebugRealloc0AlignedBlock(void* addr,size_t old_size,size_t new_size, int level); 135 extern void omDebugFreeBlock(void* addr, size_t size, int level); 136 extern void* omDebugPseudoReallocBlock(void* addr, size_t old_size, size_t new_size, int level); 137 extern void* omDebugPseudoReallo0cBlock(void* addr, size_t old_size, size_t new_size, int level); 138 extern void* omDebugPseudoReallocAlignedBlock(void* addr,size_t old_size,size_t new_size, int level); 139 extern void* omDebugPseudoRealloc0AlignedBlock(void* addr,size_t old_size,size_t new_size, int level); 140 extern void omDebugPseudoFreeBlock(void* addr, size_t size, int level); 141 142 extern void* omDebugAllocChunk(size_t size, int level); 143 extern void* omDebugAlloc0Chunk(size_t size, int level); 144 extern void* omDebugAllocAlignedChunk(size_t size, int level); 145 extern void* omDebugAlloc0AlignedChunk(size_t size, int level); 146 extern void* omDebugReallocChunk(void* addr, size_t size, int level); 147 extern void* omDebugReallocAlignedChunk(void* addr, size_t size, int level); 148 extern void omDebugFreeChunk(void* addr, int level); 149 extern void omDebugFreeAlignedChunk(void* addr, int level); 150 extern void* omDebugPseudoReallocChunk(void* addr, size_t size, int level); 151 extern void* omDebugPseudoReallocAlignedChunk(void* addr, size_t size, int level); 152 extern void omDebugPseudoFreeChunk(void* addr, int level); 153 extern void omDebugPseudoFreeAlignedChunk(void* addr, int level); 154 155 /* Debug of addr/bins -- return NULL if ok, error message, otherwise */ 156 extern char* omDebugBinAddr(void* addr, int level); 157 extern char* omDebugBin(omBin bin, int level); 158 extern char* omDebugAllBins(int level); 159 extern char* omDebugBlockAddr(void* addr, size_t size, int level); 160 extern char* omDebugAlignedBlockAddr(void* addr, size_t size, int level); 161 extern char* omDebugChunkAddr(void* addr); 162 extern char* omDebugAlignedChunkAddr(void* addr); 163 164 /* DebugReport of addr/bins -- return 1 if ok, otherwise print error and current stack 165 backtrace to stderr and return 0 */ 166 extern int omDebugReportBinAddr(void* addr, int level); 167 extern int omDebugReportBin(omBin bin, int level); 168 extern int omDebugReportAllBins(int level); 169 extern int omDebugReportBlockAddr(void* addr, size_t size, int level); 170 extern int omDebugReportAlignedBlockAddr(void* addr, size_t size, int level); 171 extern int omDebugReportChunkAddr(void* addr); 172 extern int omDebugReportAlignedChunkAddr(void* addr); 173 174 /******************************************************************* 175 * 176 * om Alloc/Free Macro definitions 177 * 178 *******************************************************************/ 179 180 #if definded(OM_DEBUG) && OM_DEBUG != 0 181 /******************************************************************* 182 * Alloc/Free for Debug 183 *******************************************************************/ 184 185 #define omTypeAllocBin(type, addr, bin) addr = (type) omDebugAllocBin(bin, OM_DEBUG) 186 #define omTypeAlloc0Bin(type, addr, bin) addr = (type) omDebugAlloc0Bin(bin, OM_DEBUG) 187 #define omAllocBin(bin) omDebugAllocBin(bin, OM_DEBUG) 188 #define omAlloc0Bin(bin) omDebugAlloc0Bin(bin, OM_DEBUG) 189 #if defined(OM_PSEUDO_FREE) && OM_PSEUDO_FREE != 0 190 #define omFreeBin(addr) omDebugPseudoFreeBin(addr, OM_DEBUG) 191 #else 192 #define omFreeBin(addr) omDebugFreeBin(addr, OM_DEBUG) 193 #endif 194 195 #define omTypeAllocBlock(type, addr, size) addr = (type) omDebugAllocBlock(size, OM_DEBUG) 196 #define omTypeAlloc0Block(type, addr, size) addr = (type) omDebugAlloc0Block(size, OM_DEBUG) 197 #define omAllocBlock(size) omDebugAllocBlock(size, OM_DEBUG) 198 #define omAlloc0Block(size) omDebugAlloc0Block(size, OM_DEBUG) 199 #define omTypeAllocAlignedBlock(type, addr, size) addr = (type) omDebugAllocAlignedBlock(size, OM_DEBUG) 200 #define omTypeAlloc0AlignedBlock(type, addr, size) addr = (type) omDebugAlloc0AlignedBlock(size, OM_DEBUG) 201 #define omAllocAlignedBlock(size) omDebugAllocAlignedBlock(size, OM_DEBUG) 202 #define omAlloc0AlignedBlock(size) omDebugAlloc0AlignedBlock(size, OM_DEBUG) 203 #if defined(OM_PSEUDO_FREE) && OM_PSEUDO_FREE != 0 204 #define omReallocBlock(addr, old_size, new_size) omDebugPseudoReallocBlock(addr, old_size, new_size, OM_DEBUG) 205 #define omRealloc0Block(addr, old_size, new_size) omDebugPseudoRealloc0Block(addr, old_size, new_size, OM_DEBUG) 206 #define omReallocAlignedBlock(addr, old_size, new_size) omDebugPseudoReallocAlignedBlock(addr, old_size, new_size, OM_DEBUG) 207 #define omRealloc0AlignedBlock(addr, old_size, new_size) omDebugPseudoRealloc0AlignedBlock(addr, old_size, new_size, OM_DEBUG) 208 #define omFreeBlock(addr, size) omDebugPseudoFreeBlock(addr, size, OM_DEBUG) 209 #else 210 #define omReallocBlock(addr, old_size, new_size) omDebugReallocBlock(addr, old_size, new_size, OM_DEBUG) 211 #define omRealloc0Block(addr, old_size, new_size) omDebugRealloc0Block(addr, old_size, new_size, OM_DEBUG) 212 #define omReallocAlignedBlock(addr, old_size, new_size) omDebugReallocAlignedBlock(addr, old_size, new_size, OM_DEBUG) 213 #define omRealloc0AlignedBlock(addr, old_size, new_size) omDebugRealloc0AlignedBlock(addr, old_size, new_size, OM_DEBUG) 214 #define omFreeBlock(addr, size) omDebugFreeBlock(addr, size, OM_DEBUG) 215 #endif 216 217 #define omTypeAllocChunk(type, addr, size) addr = (type) omDebugAllocChunk(size, OM_DEBUG) 218 #define omTypeAlloc0Chunk(type, addr, size) addr = (type) omDebugAlloc0Chunk(size, OM_DEBUG) 219 #define omAllocChunk(size) omDebugAllocChunk(size, OM_DEBUG) 220 #define omAlloc0Chunk(size) omDebugAlloc0Chunk(size, OM_DEBUG) 221 #define omTypeAllocAlignedChunk(type, addr, size) addr = (type) omDebugAllocAlignedChunk(size, OM_DEBUG) 222 #define omTypeAlloc0AlignedChunk(type, addr, size) addr = (type) omDebugAlloc0AlignedChunk(size, OM_DEBUG) 223 #define omAllocAlignedChunk(size) omDebugAllocAlignedChunk(size, OM_DEBUG) 224 #define omAlloc0AlignedChunk(size) omDebugAlloc0AlignedChunk(size, OM_DEBUG) 225 #if defined(OM_PSEUDO_FREE) && OM_PSEUDO_FREE != 0 226 #define omReallocChunk(addr, new_size) omDebugPseudoReallocChunk(addr, new_size, OM_DEBUG) 227 #define omReallocAlignedChunk(addr, new_size) omDebugPseudoReallocAlignedChunk(addr, new_size, OM_DEBUG) 228 #define omFreeChunk(addr) omDebugPseudoFreeChunk(addr, OM_DEBUG) 229 #define omFreeAlignedChunk(addr) omDebugPseudoFreeAlignedChunk(addr, OM_DEBUG) 230 #else 231 #define omReallocChunk(addr, new_size) omDebugReallocChunk(addr, new_size, OM_DEBUG) 232 #define omReallocAlignedChunk(addr, new_size) omDebugReallocAlignedChunk(addr, new_size, OM_DEBUG) 233 #define omFreeChunk(addr) omDebugFreeChunk(addr, OM_DEBUG) 234 #define omFreeAlignedChunk(addr) omDebugFreeAlignedChunk(addr, OM_DEBUG) 235 #endif 236 237 238 #define omTestBinAddr(addr) omDebugBinAddr(addr, OM_DEBUG) 239 #define omTestBlockAddr(addr, size) omDebugBlockAddr(addr, size, OM_DEBUG) 240 #define omTestAlignedBlockAddr(addr, size) omDebugAlignedBlockAddr(addr, size, OM_DEBUG) 241 #define omTestChunkAddr(addr) omDebugBlockAddr(addr, size, OM_DEBUG) 242 #define omTestAlignedChunkAddr(addr) omDebugAlignedBlockAddr(addr, size, OM_DEBUG) 243 244 #define omTestReportBinAddr(addr) omDebugReportBinAddr(addr, OM_DEBUG) 245 #define omTestReportBlockAddr(addr, size) omDebugReportBlockAddr(addr, size, OM_DEBUG) 246 #define omTestReportAlignedBlockAddr(addr, size) omDebugReportAlignedBlockAddr(addr, size, OM_DEBUG) 247 #define omTestReportChunkAddr(addr) omDebugReportBlockAddr(addr, size, OM_DEBUG) 248 #define omTestReportAlignedChunkAddr(addr) omDebugReportAlignedBlockAddr(addr, size, OM_DEBUG) 249 250 #define omTestUsedAddrs() omDebugUsedAddrs(OM_DEBUG) 251 #define omTestFreeAddrs() omDebugFreeAddrs(OM_DEBUG) 252 #define omTestAllAddrs() omDebugAllAddrs(OM_DEBUG) 253 #define omTestReportUsedAddrs() omDebugReportUsedAddrs(OM_DEBUG) 254 #define omTestReportFreeAddrs() omDebugReportFreeAddrs(OM_DEBUG) 255 #define omTestReportAllAddrs() omDebugReportAllAddrs(OM_DEBUG) 256 257 #elsif defined(OM_CHECK) && OM_CHECK != 0 258 /******************************************************************* 259 * Alloc/Free for Check 260 *******************************************************************/ 261 262 #define omTypeAllocBin(type, addr, bin) addr = (type) omCheckAllocBin(bin, OM_DEBUG) 263 #define omTypeAlloc0Bin(type, addr, bin) addr = (type) omCheckAlloc0Bin(bin, OM_DEBUG) 264 #define omAllocBin(bin) omCheckAllocBin(bin, OM_DEBUG) 265 #define omAlloc0Bin(bin) omCheckAlloc0Bin(bin, OM_DEBUG) 266 #if defined(OM_PSEUDO_FREE) && OM_PSEUDO_FREE != 0 267 #define omFreeBin(addr) omCheckPseudoFreeBin(addr, OM_DEBUG) 268 #else 269 #define omFreeBin(addr) omCheckFreeBin(addr, OM_DEBUG) 270 #endif 271 272 #define omTypeAllocBlock(type, addr, size) addr = (type) omCheckAllocBlock(size, OM_DEBUG) 273 #define omTypeAlloc0Block(type, addr, size) addr = (type) omCheckAlloc0Block(size, OM_DEBUG) 274 #define omAllocBlock(size) omCheckAllocBlock(size, OM_DEBUG) 275 #define omAlloc0Block(size) omCheckAlloc0Block(size, OM_DEBUG) 276 #define omTypeAllocAlignedBlock(type, addr, size) addr = (type) omCheckAllocAlignedBlock(size, OM_DEBUG) 277 #define omTypeAlloc0AlignedBlock(type, addr, size) addr = (type) omCheckAlloc0AlignedBlock(size, OM_DEBUG) 278 #define omAllocAlignedBlock(size) omCheckAllocAlignedBlock(size, OM_DEBUG) 279 #define omAlloc0AlignedBlock(size) omCheckAlloc0AlignedBlock(size, OM_DEBUG) 280 #if defined(OM_PSEUDO_FREE) && OM_PSEUDO_FREE != 0 281 #define omReallocBlock(addr, old_size, new_size) omCheckPseudoReallocBlock(addr, old_size, new_size, OM_DEBUG) 282 #define omRealloc0Block(addr, old_size, new_size) omCheckPseudoRealloc0Block(addr, old_size, new_size, OM_DEBUG) 283 #define omReallocAlignedBlock(addr, old_size, new_size) omCheckPseudoReallocAlignedBlock(addr, old_size, new_size, OM_DEBUG) 284 #define omRealloc0AlignedBlock(addr, old_size, new_size) omCheckPseudoRealloc0AlignedBlock(addr, old_size, new_size, OM_DEBUG) 285 #define omFreeBlock(addr, size) omCheckPseudoFreeBlock(addr, size, OM_DEBUG) 286 #else 287 #define omReallocBlock(addr, old_size, new_size) omCheckReallocBlock(addr, old_size, new_size, OM_DEBUG) 288 #define omRealloc0Block(addr, old_size, new_size) omCheckRealloc0Block(addr, old_size, new_size, OM_DEBUG) 289 #define omReallocAlignedBlock(addr, old_size, new_size) omCheckReallocAlignedBlock(addr, old_size, new_size, OM_DEBUG) 290 #define omRealloc0AlignedBlock(addr, old_size, new_size) omCheckRealloc0AlignedBlock(addr, old_size, new_size, OM_DEBUG) 291 #define omFreeBlock(addr, size) omCheckFreeBlock(addr, size, OM_DEBUG) 292 #endif 293 294 #define omTypeAllocChunk(type, addr, size) addr = (type) omCheckAllocChunk(size, OM_DEBUG) 295 #define omTypeAlloc0Chunk(type, addr, size) addr = (type) omCheckAlloc0Chunk(size, OM_DEBUG) 296 #define omAllocChunk(size) omCheckAllocChunk(size, OM_DEBUG) 297 #define omAlloc0Chunk(size) omCheckAlloc0Chunk(size, OM_DEBUG) 298 #define omTypeAllocAlignedChunk(type, addr, size) addr = (type) omCheckAllocAlignedChunk(size, OM_DEBUG) 299 #define omTypeAlloc0AlignedChunk(type, addr, size) addr = (type) omCheckAlloc0AlignedChunk(size, OM_DEBUG) 300 #define omAllocAlignedChunk(size) omCheckAllocAlignedChunk(size, OM_DEBUG) 301 #define omAlloc0AlignedChunk(size) omCheckAlloc0AlignedChunk(size, OM_DEBUG) 302 #if defined(OM_PSEUDO_FREE) && OM_PSEUDO_FREE != 0 303 #define omReallocChunk(addr, new_size) omCheckPseudoReallocChunk(addr, new_size, OM_DEBUG) 304 #define omReallocAlignedChunk(addr, new_size) omCheckPseudoReallocAlignedChunk(addr, new_size, OM_DEBUG) 305 #define omFreeChunk(addr) omCheckPseudoFreeChunk(addr, OM_DEBUG) 306 #define omFreeAlignedChunk(addr) omCheckPseudoFreeAlignedChunk(addr, OM_DEBUG) 307 #else 308 #define omReallocChunk(addr, new_size) omCheckReallocChunk(addr, new_size, OM_DEBUG) 309 #define omReallocAlignedChunk(addr, new_size) omCheckReallocAlignedChunk(addr, new_size, OM_DEBUG) 310 #define omFreeChunk(addr) omCheckFreeChunk(addr, OM_DEBUG) 311 #define omFreeAlignedChunk(addr) omCheckFreeAlignedChunk(addr, OM_DEBUG) 312 #endif 313 314 315 #define omTestBinAddr(addr) omCheckBinAddr(addr, OM_DEBUG) 316 #define omTestBlockAddr(addr, size) omCheckBlockAddr(addr, size, OM_DEBUG) 317 #define omTestAlignedBlockAddr(addr, size) omCheckAlignedBlockAddr(addr, size, OM_DEBUG) 318 #define omTestChunkAddr(addr) omCheckBlockAddr(addr, size, OM_DEBUG) 319 #define omTestAlignedChunkAddr(addr) omCheckAlignedBlockAddr(addr, size, OM_DEBUG) 320 321 #define omTestReportBinAddr(addr) omCheckReportBinAddr(addr, OM_DEBUG) 322 #define omTestReportBlockAddr(addr, size) omCheckReportBlockAddr(addr, size, OM_DEBUG) 323 #define omTestReportAlignedBlockAddr(addr, size) omCheckReportAlignedBlockAddr(addr, size, OM_DEBUG) 324 #define omTestReportChunkAddr(addr) omCheckReportBlockAddr(addr, size, OM_DEBUG) 325 #define omTestReportAlignedChunkAddr(addr) omCheckReportAlignedBlockAddr(addr, size, OM_DEBUG) 326 327 #define omTestUsedAddrs() omCheckUsedAddrs(OM_DEBUG) 328 #define omTestFreeAddrs() omCheckFreeAddrs(OM_DEBUG) 329 #define omTestAllAddrs() omCheckAllAddrs(OM_DEBUG) 330 #define omTestReportUsedAddrs() omCheckReportUsedAddrs(OM_DEBUG) 331 #define omTestReportFreeAddrs() omCheckReportFreeAddrs(OM_DEBUG) 332 #define omTestReportAllAddrs() omCheckReportAllAddrs(OM_DEBUG) 333 334 335 #else 336 /******************************************************************* 337 * Alloc/Free -- the real thing 338 *******************************************************************/ 339 340 #define omTypeAllocBin(type, addr, bin) __omTypeAllocBin(type, addr, bin) 341 #define omTypeAlloc0Bin(type, addr, bin) __omTypeAllocBin(type, addr, bin) 342 #define omAllocBin(bin) _omAllocBin(bin) 343 #define omAlloc0Bin(bin) _omAlloc0Bin(bin) 344 #if defined(OM_PSEUDO_FREE) && OM_PSEUDO_FREE != 0 345 #define omFreeBin(addr) _omPseudoFreeBin(addr) 346 #else 347 #define omFreeBin(addr) __omFreeBin(addr) 348 #endif 349 350 #define omTypeAllocBlock(type, addr, size) __omTypeAllocBlock(type, addr, size) 351 #define omTypeAlloc0Block(type, addr, size) __omTypeAlloc0Block(type, addr, size) 352 #define omAllocBlock(size) _omAllocBlock(size) 353 #define omAlloc0Block(size) _omAlloc0Block(size) 354 #define omTypeAllocAlignedBlock(type, addr, size) __omTypeAllocAlignedBlock(type, addr, size) 355 #define omTypeAlloc0AlignedBlock(type, addr, size) __omTypeAlloc0AlignedBlock(type, addr, size) 356 #define omAllocAlignedBlock(size) _omAllocAlignedBlock(size) 357 #define omAlloc0AlignedBlock(size) _omAlloc0AlignedBlock(size) 358 #if defined(OM_PSEUDO_FREE) && OM_PSEUDO_FREE != 0 359 #define omReallocBlock(addr, old_size, new_size) _omPseudoReallocBlock(addr, old_size, new_size) 360 #define omRealloc0Block(addr, old_size, new_size) _omPseudoRealloc0Block(addr, old_size, new_size) 361 #define omReallocAlignedBlock(addr, old_size, new_size) _omPseudoReallocAlignedBlock(addr, old_size, new_size) 362 #define omRealloc0AlignedBlock(addr, old_size, new_size) _omPseudoRealloc0AlignedBlock(addr, old_size, new_size) 363 #define omFreeBlock(addr, size) _omPseudoFreeBlock(addr, size) 364 #else 365 #define omReallocBlock(addr, old_size, new_size) _omReallocBlock(addr, old_size, new_size) 366 #define omRealloc0Block(addr, old_size, new_size) _omRealloc0Block(addr, old_size, new_size) 367 #define omReallocAlignedBlock(addr, old_size, new_size) _omReallocAlignedBlock(addr, old_size, new_size) 368 #define omRealloc0AlignedBlock(addr, old_size, new_size) _omRealloc0AlignedBlock(addr, old_size, new_size) 369 #define omFreeBlock(addr, size) __FreeBlock(addr, size) 370 #endif 371 372 #define omTypeAllocChunk(type, addr, size) __omAllocChunk(type, addr, size) 373 #define omTypeAlloc0Chunk(type, addr, size) __omAlloc0Chunk(type, addr, size) 374 #define omAllocChunk(size) _omAllocChunk(size) 375 #define omAlloc0Chunk(size) _omAlloc0Chunk(size) 376 #define omTypeAllocAlignedChunk(type, addr, size) __omTypeAllocAlignedChunk(type, addr, size) 377 #define omTypeAlloc0AlignedChunk(type, addr, size) __omTypeAlloc0AlignedChunk(type, addr, size) 378 #define omAllocAlignedChunk(size) _omAllocAlignedChunk(size) 379 #define omAlloc0AlignedChunk(size) _omAllocAlignedChunk(size) 380 #if defined(OM_PSEUDO_FREE) && OM_PSEUDO_FREE != 0 381 #define omReallocChunk(addr, new_size) _omPseudoReallocChunk(addr, new_size) 382 #define omReallocAlignedChunk(addr, new_size) _omPseudoReallocAlignedChunk(addr, new_size) 383 #define omFreeChunk(addr) _omPseudoFreeChunk(addr) 384 #define omFreeAlignedChunk(addr) _omPseudoFreeAlignedChunk(addr) 385 #else 386 #define omReallocChunk(addr, new_size) _omReallocChunk(addr, new_size) 387 #define omReallocAlignedChunk(addr, new_size) _omReallocAlignedChunk(addr, new_size) 388 #define omFreeChunk(addr) _omFreeChunk(addr) 389 #define omFreeAlignedChunk(addr) _omFreeAlignedChunk(addr) 390 #endif 391 392 393 #define omTestBinAddr(addr) (NULL) 394 #define omTestBlockAddr(addr, size) (NULL) 395 #define omTestAlignedBlockAddr(addr, size) (NULL) 396 #define omTestChunkAddr(addr) (NULL) 397 #define omTestAlignedChunkAddr(addr) (NULL) 398 399 #define omTestReportBinAddr(addr) (1) 400 #define omTestReportBlockAddr(addr, size) (1) 401 #define omTestReportAlignedBlockAddr(addr, size) (1) 402 #define omTestReportChunkAddr(addr) (1) 403 #define omTestReportAlignedChunkAddr(addr) (1) 404 405 #define omTestUsedAddrs() (NULL) 406 #define omTestFreeAddrs() (NULL) 407 #define omTestAllAddrs() (NULL) 408 #define omTestReportUsedAddrs() (1) 409 #define omTestReportFreeAddrs() (1) 410 #define omTestReportAllAddrs() (1) 411 412 #endif /* om Macro definitions */ 413 414 /******************************************************************* 415 * 416 * Bin stuff 417 * 418 *******************************************************************/ 419 omBin omGetSpecBin(size_t size); 420 omBin omGetAlignedSpecBin(size_t size); 421 void omUnGetSpecBin(omBin *bin); 422 423 unsigned long omGetNewStickyBinTag(omBin bin); 424 void omSetStickyBinTag(omBin bin, unsigned long sticky); 425 void omUnSetStickyBinTag(omBin bin, unsigned long sticky); 426 void omDeleteStickyBinTag(omBin bin, unsigned long sticky); 427 428 unsigned long omGetNewStickyAllBinTag(); 429 void omSetStickyAllBinTag(omBin bin, unsigned long sticky); 430 void omUnSetStickyAllBinTag(omBin bin, unsigned long sticky); 431 void omDeleteStickyAllBinTag(omBin bin, unsigned long sticky); 432 433 #include <stdio.h> 434 extern void omPrintBinStats(FILE* fd); 435 extern void omPrintBinStat(FILE * fd, omBin bin); 436 437 438 439 #else /* OM_USE_EXTERNAL_MALLOC */ 440 441 /******************************************************************* 442 * 443 * Alternative set of defines 444 * 445 *******************************************************************/ 446 typedef size_t omBin; 447 typedef size_t omSpecBin; 448 449 #define omTypeAllocBin(type, addr, bin) addr = (type) malloc(bin) 450 #define omTypeAlloc0Bin(type, addr, bin) do {addr = (type) malloc(bin); memset(addr, 0, bin);} while(0) 451 #define omAllocBin(bin) malloc(bin) 452 #define omAlloc0Bin(bin) omAlternativeMalloc0(bin) 453 #define omFreeBin(addr) free(addr) 454 455 #define omTypeAllocBlock(type, addr, size) addr = (type) malloc(size) 456 #define omTypeAlloc0Block(type, addr, size) do {addr = (type) malloc(size); memset(addr, 0, size);} while(0) 457 #define omAllocBlock(size) malloc(size) 458 #define omAlloc0Block(size) omAlternativeMalloc0(size) 459 #define omTypeAllocAlignedBlock(type, addr, size) addr = (type) malloc(size) 460 #define omTypeAlloc0AlignedBlock(type, addr, size) do {addr = (type) malloc(size); memset(addr, 0, size);} while(0) 461 #define omAllocAlignedBlock(size) malloc(size) 462 #define omAlloc0AlignedBlock(size) omAlternativeMalloc0(size) 463 #define omReallocBlock(addr, old_size, new_size) realloc(addr, new_size) 464 #define omRealloc0Block(addr, old_size, new_size) omAlternativeRealloc0Block(addr, old_size, new_size) 465 #define omReallocAlignedBlock(addr, old_size, new_size) realloc(addr, new_size) 466 #define omRealloc0AlignedBlock(addr, old_size, new_size) omAlternativeRealloc0Block(addr, old_size, new_size) 467 #define omFreeBlock(addr, size) free(addr) 468 469 #define omTypeAllocChunk(type, addr, size) addr = (type) malloc(size) 470 #define omTypeAlloc0Chunk(type, addr, size) do {addr = (type) malloc(size); memset(addr, 0, size);} while(0) 471 #define omAllocChunk(size) malloc(size) 472 #define omAlloc0Chunk(size) omAlternativeMalloc0(size) 473 #define omTypeAllocAlignedChunk(type, addr, size) addr = (type) malloc(size) 474 #define omTypeAlloc0AlignedChunk(type, addr, size) do {addr = (type) malloc(size); memset(addr, 0, size);} while(0) 475 #define omAllocAlignedChunk(size) malloc(size) 476 #define omAlloc0AlignedChunk(size) omAlternativeMalloc0(size) 477 #define omReallocChunk(addr, new_size) realloc(addr, new_size) 478 #define omAlignedReallocChunk(addr, new_size) realloc(addr, new_size) 479 #define omFreeChunk(addr) free(addr) 480 #define omFreeAlignedChunk(addr) free(addr) 481 482 483 #define omTestBinAddr(addr) (NULL) 484 #define omTestBlockAddr(addr, size) (NULL) 485 #define omTestAlignedBlockAddr(addr, size) (NULL) 486 #define omTestChunkAddr(addr) (NULL) 487 #define omTestAlignedChunkAddr(addr) (NULL) 488 489 #define omTestReportBinAddr(addr) (1) 490 #define omTestReportBlockAddr(addr, size) (1) 491 #define omTestReportAlignedBlockAddr(addr, size) (1) 492 #define omTestReportChunkAddr(addr) (1) 493 #define omTestReportAlignedChunkAddr(addr) (1) 494 495 #define omTestUsedAddrs() (NULL) 496 #define omTestFreeAddrs() (NULL) 497 #define omTestAllAddrs() (NULL) 498 #define omTestReportUsedAddrs() (1) 499 #define omTestReportFreeAddrs() (1) 500 #define omTestReportAllAddrs() (1) 501 502 #endif /* OM_USE_EXTERNAL_MALLOC */ 189 503 190 504 #endif /* OM_ALLOC_H */ -
omalloc/omLocal.h
ra89a22c rba6f0c 5 5 * Author: obachman (Olaf Bachmann) 6 6 * Created: 11/99 7 * Version: $Id: omLocal.h,v 1. 2 1999-11-22 18:12:59obachman Exp $7 * Version: $Id: omLocal.h,v 1.3 1999-11-26 17:57:53 obachman Exp $ 8 8 *******************************************************************/ 9 9 #ifndef OM_LOCAL_H … … 73 73 * 74 74 *******************************************************************/ 75 #include <stdio.h>76 75 extern int omIsStaticBin(omBin bin); 77 extern void omPrintBinStats(FILE* fd);78 extern void omPrintBinStat(FILE * fd, omBin bin);79 76 80 77 /******************************************************************* -
omalloc/omPrivate.h
ra89a22c rba6f0c 5 5 * Author: obachman (Olaf Bachmann) 6 6 * Created: 11/99 7 * Version: $Id: omPrivate.h,v 1. 3 1999-11-23 20:40:13obachman Exp $7 * Version: $Id: omPrivate.h,v 1.4 1999-11-26 17:57:54 obachman Exp $ 8 8 *******************************************************************/ 9 9 #ifndef OM_PRIVATE_H … … 42 42 *******************************************************************/ 43 43 struct omBinPage_s; 44 struct omBin_s;45 struct omSpecBin_s;46 44 typedef struct omBinPage_s omBinPage_t; 47 typedef struct omBin_s omBin_t;48 typedef struct omSpecBin_s omSpecBin_t;49 45 typedef omBinPage_t* omBinPage; 50 typedef omBin_t* omBin;51 typedef omSpecBin_t* omSpecBin;52 46 53 47 … … 102 96 #include "omTables.inc" 103 97 104 105 106 98 /******************************************************************* 107 99 * … … 364 356 while (0) 365 357 366 367 358 #else /* ! OM_ALIGNMENT_NEEDS_WORK */ 368 359 #define __omTypeAllocAlignedChunk __omTypeAllocChunk … … 426 417 OM_FREE_FUNC_WRAPPER(FreeChunk) 427 418 419 #ifdef OM_ALIGNMENT_NEEDS_WORK 420 OM_ALLOCSIZE_FUNC_WRAPPER(AllocAlignedBlock) 421 OM_ALLOCSIZE_FUNC_WRAPPER(Alloc0AlignedBlock) 422 OM_ALLOCSIZE_FUNC_WRAPPER(AllocAlignedChunk) 423 OM_ALLOCSIZE_FUNC_WRAPPER(Alloc0AlignedChunk) 424 OM_FREE_FUNC_WRAPPER(FreeAlignedChunk) 425 #else 426 #define _omAllocAlignedBlock _omAllocBlock 427 #define _omAlloc0AlignedBlock _omAlloc0Block 428 #define _omAllocAlignedChunk _omAllocChunk 429 #define _omFreeAlignedChunk _omFreeChunk 430 #endif /* OM_ALIGNMENT_NEEDS_WORK */ 431 428 432 #else /* ! OM_INLINE */ 429 433 … … 431 435 #define _omAlloc0Bin omFuncAlloc0Bin 432 436 #define _omFreeBin omFuncFreeBin 433 #define _omAllocBlock omFuncAllocBlock 434 #define _omAlloc0Block omFuncAlloc0Block 435 #define _omFreeBlock omFuncFreeBlock 436 #define _omAlloc omFuncAlloc 437 #define _omAlloc0 omFuncAlloc0 438 #define _omFree omFuncFree 437 #define _omAllocBlock omFuncAllocBlock 438 #define _omAlloc0Block omFuncAlloc0Block 439 #define _omFreeBlock omFuncFreeBlock 440 #define _omAlloc omFuncAlloc 441 #define _omAlloc0 omFuncAlloc0 442 #define _omFree omFuncFree 443 #define _omAllocAlignedBlock omFuncAllocAlignedBlock 444 #define _omAlloc0AlignedBlock omFuncAlloc0AlignedBlock 445 #define _omAllocAlignedChunk omFuncAllocAlignedChunk 446 #define _omFreeAlignedChunk omFuncFreeAlignedChunk 439 447 440 448 #endif /* OM_INLINE */ 441 449 442 omBin omGetSpecBin(size_t size); 443 void omUnGetSpecBin(omBin *bin); 444 unsigned long omGetNewStickyAllBinTag(); 445 void omSetStickyAllBinTag(unsigned long sticky); 446 void omUnSetStickyAllBinTag(unsigned long sticky); 447 void omDeleteStickyAllBinTag(unsigned long sticky); 450 void* _omReallocBlock(void* old_addr, size_t old_size, size_t new_size); 451 void* _omRealloc0Block(void* old_addr, size_t old_size, size_t new_size); 452 void* _omReallocChunk(void* old_addr, size_t new_size); 453 454 #ifdef OM_ALIGNMENT_NEEDS_WORK 455 void* _omReallocAlignedBlock(void* old_addr, size_t old_size, size_t new_size); 456 void* _omRealloc0AlignedBlock(void* old_addr, size_t old_size,size_t new_size); 457 void* _omReallocAlignedChunk(void* old_addr, size_t new_size); 458 #else 459 #define _omReallocAlignedBlock _omRealllocBlock 460 #define _omRealloc0AlignedBlock _omReallloc0Block 461 #define _omReallocAlignedChunk _omReallocChunk 462 #endif 463 464 /******************************************************************* 465 * 466 * Declaration of Func 467 * 468 *******************************************************************/ 469 void* omFuncAllocBin(omBin bin); 470 void* omFuncAlloc0Bin(omBin bin); 471 void omFuncFreeBin(void* addr); 472 473 void* omFuncAllocBlock(size_t size); 474 void* omFuncAlloc0Block(size_t size); 475 void omFuncFreeBlock(void* addr, size_t size); 476 #define omFuncReallocBlock _omReallocBlock 477 #define omFuncRealloc0Block _omRealloc0Block 478 479 void* omFuncAllocChunk(size_t size); 480 void* omFuncAlloc0Chunk(size_t size); 481 void omFuncFreeChunk(void* addr); 482 #define omFuncReallocChunk _omReallocChunk 483 484 #ifdef OM_ALIGNMENT_NEEDS_WORK 485 void* omFuncAllocAlignedBlock(size_t size); 486 void* omFuncAlloc0AlignedBlock(size_t size); 487 #define omFuncReallocAlignedBlock _omReallocAlignedBlock 488 #define omFuncRealloc0AlignedBlock _omRealloc0AlignedBlock 489 490 void* omFuncAllocAlignedChunk(size_t size); 491 void* omFuncAllocAligned0Chunk(size_t size); 492 void omFuncFreeAlignedChunk(void* addr); 493 #define omFuncReallocAlignedChunk _omReallocAlignedChunk 494 #else 495 #define omFuncAllocAlignedBlock omFuncAllocBlock 496 #define omFuncAlloc0AlignedBlock omFuncAlloc0Block 497 #define omFuncReallocAlignedBlock omFuncReallocBlock 498 #define omFuncRealloc0AlignedBlock omFuncRealloc0Block 499 500 #define omFuncAllocAlignedChunk omFuncAllocChunk 501 #define omFuncAlloc0AlignedChunk omFuncAlloc0Chunk 502 #define omFuncReallocAlignedChunk omFuncReallocBlock 503 #define omFuncFreeAlignedChunk omFuncFreeChunk 504 #endif /* OM_ALIGNMENT_NEEDS_WORK */ 505 506 448 507 449 508 #endif /* ! OM_GENERATE_INC */
Note: See TracChangeset
for help on using the changeset viewer.