1 | /******************************************************************* |
---|
2 | * File: omAllocDecl.h |
---|
3 | * Purpose: declaration of Alloc routines |
---|
4 | * Author: obachman (Olaf Bachmann) |
---|
5 | * Created: 11/99 |
---|
6 | * Version: $Id: omAllocDecl.h,v 1.10 2006-05-02 13:03:15 Singular Exp $ |
---|
7 | *******************************************************************/ |
---|
8 | #ifndef OM_ALLOC_DECL_H |
---|
9 | #define OM_ALLOC_DECL_H |
---|
10 | |
---|
11 | #ifdef OM_NDEBUG |
---|
12 | #if (SIZEOF_LONG == 8) |
---|
13 | #define OM_T_FREE1 |
---|
14 | #define OM_T_FREE3 |
---|
15 | #define OM_T_STR |
---|
16 | #define OM_T_ALLOC |
---|
17 | #define OM_T_REALLOC |
---|
18 | #undef OM_NDEBUG |
---|
19 | #endif |
---|
20 | #endif |
---|
21 | |
---|
22 | |
---|
23 | #if !defined(OMALLOC_C) && !defined(OM_NO_MALLOC_MACROS) |
---|
24 | #define calloc omcalloc |
---|
25 | #define malloc omalloc |
---|
26 | #define free omfree |
---|
27 | #define realloc omrealloc |
---|
28 | #define freeSize omfreeSize |
---|
29 | #define reallocSize omreallocSize |
---|
30 | #endif |
---|
31 | |
---|
32 | #if (!defined(OM_EMULATE_OMALLOC) && !defined(OM_NDEBUG) && (defined(OM_CHECK) || (defined(OM_HAVE_TRACK) && defined(OM_TRACK)))) || defined(OM_T1) |
---|
33 | |
---|
34 | /******************************************************************* |
---|
35 | * |
---|
36 | * Alloc/Free/Check for Debug |
---|
37 | * |
---|
38 | *******************************************************************/ |
---|
39 | #ifndef OM_CHECK |
---|
40 | #define OM_CHECK 0 |
---|
41 | #endif |
---|
42 | #ifndef OM_TRACK |
---|
43 | #define OM_TRACK 0 |
---|
44 | #endif |
---|
45 | |
---|
46 | #if OM_KEEP > 0 |
---|
47 | #define _OM_FKEEP OM_FKEEP |
---|
48 | #else |
---|
49 | #define _OM_FKEEP 0 |
---|
50 | #endif |
---|
51 | |
---|
52 | #if !defined(OM_T_ALLOC) |
---|
53 | #define omTypeAllocBin(type,addr,bin) addr=(type)_omDebugAlloc(bin,OM_FBIN|_OM_FKEEP,OM_CTFL) |
---|
54 | #define omTypeAlloc0Bin(type,addr,bin) addr=(type)_omDebugAlloc(bin,OM_FBIN|OM_FZERO|_OM_FKEEP,OM_CTFL) |
---|
55 | #define omAllocBin(bin) _omDebugAlloc(bin,OM_FBIN|_OM_FKEEP,OM_CTFL) |
---|
56 | #define omAlloc0Bin(bin) _omDebugAlloc(bin,OM_FBIN|OM_FZERO|_OM_FKEEP,OM_CTFL) |
---|
57 | |
---|
58 | #define omTypeAlloc(type,addr,size) addr=(type)_omDebugAlloc((void*)(size),OM_FSIZE|_OM_FKEEP,OM_CTFL) |
---|
59 | #define omTypeAlloc0(type,addr,size) addr=(type)_omDebugAlloc((void*)(size),OM_FSIZE|OM_FZERO|_OM_FKEEP,OM_CTFL) |
---|
60 | #define omAlloc(size) _omDebugAlloc((void*)(size),OM_FSIZE|_OM_FKEEP,OM_CTFL) |
---|
61 | #define omAlloc0(size) _omDebugAlloc((void*)(size),OM_FSIZE|OM_FZERO|_OM_FKEEP,OM_CTFL) |
---|
62 | |
---|
63 | #define omalloc(size) _omDebugAlloc((void*)(size),OM_FSIZE|OM_FSLOPPY|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
64 | #define omalloc0(size) _omDebugAlloc((void*)(size),OM_FSIZE|OM_FZERO|OM_FSLOPPY|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
65 | #define omcalloc(n,size)_omDebugAlloc((void*) ((size)*n),OM_FSIZE|OM_FZERO|OM_FSLOPPY|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
66 | |
---|
67 | #else |
---|
68 | #define omTypeAllocBin(type,addr,bin) __omTypeAllocBin(type,addr,bin) |
---|
69 | #define omTypeAlloc0Bin(type,addr,bin) __omTypeAlloc0Bin(type,addr,bin) |
---|
70 | #define omAllocBin(bin) _omAllocBin(bin) |
---|
71 | #define omAlloc0Bin(bin) _omAlloc0Bin(bin) |
---|
72 | |
---|
73 | #define omTypeAlloc(type,addr,size) __omTypeAlloc(type,addr,size) |
---|
74 | #define omTypeAlloc0(type,addr,size) __omTypeAlloc0(type,addr,size) |
---|
75 | #define omAlloc(size) _omAlloc(size) |
---|
76 | #define omAlloc0(size) _omAlloc0(size) |
---|
77 | |
---|
78 | #define omalloc(size) _omalloc(size) |
---|
79 | #define omalloc0(size) _omalloc0(size) |
---|
80 | #define omcalloc(n,size)_omalloc0(n*size) |
---|
81 | |
---|
82 | #endif |
---|
83 | |
---|
84 | #if !defined(OM_T_REALLOC) |
---|
85 | #define omTypeReallocBin(o_addr,o_bin,type,addr,bin) addr=(type)_omDebugRealloc(o_addr,o_bin,bin,OM_FBIN|_OM_FKEEP,OM_FBIN|_OM_FKEEP,OM_CTFL) |
---|
86 | #define omTypeRealloc0Bin(o_addr,o_bin,type,addr,bin) addr=(type)_omDebugRealloc(o_addr,o_bin,bin,OM_FBIN|_OM_FKEEP,OM_FBIN|OM_FZERO|_OM_FKEEP,OM_CTFL) |
---|
87 | #define omReallocBin(o_addr,o_bin,bin) _omDebugRealloc(o_addr,o_bin,bin,OM_FBIN|_OM_FKEEP,OM_FBIN|_OM_FKEEP,OM_CTFL) |
---|
88 | #define omRealloc0Bin(o_addr,o_bin,bin) _omDebugRealloc(o_addr,o_bin,bin,OM_FBIN|_OM_FKEEP,OM_FBIN|OM_FZERO|_OM_FKEEP,OM_CTFL) |
---|
89 | |
---|
90 | #define omTypeReallocSize(o_addr,o_size,type,addr,size) addr=(type)_omDebugRealloc(o_addr,(void*)(o_size),(void*)(size),OM_FSIZE|_OM_FKEEP,OM_FSIZE|_OM_FKEEP,OM_CTFL) |
---|
91 | #define omTypeRealloc0Size(o_addr,o_size,type,addr,size) addr=(type)_omDebugRealloc(o_addr,(void*)(o_size),(void*)(size),OM_FSIZE|_OM_FKEEP,OM_FSIZE|OM_FZERO|_OM_FKEEP,OM_CTFL) |
---|
92 | #define omReallocSize(addr,o_size,size) _omDebugRealloc(addr,(void*)(o_size),(void*)(size),OM_FSIZE|_OM_FKEEP,OM_FSIZE|_OM_FKEEP,OM_CTFL) |
---|
93 | #define omRealloc0Size(addr,o_size,size) _omDebugRealloc(addr,(void*)(o_size),(void*)(size),OM_FSIZE|_OM_FKEEP,OM_FSIZE|OM_FZERO|_OM_FKEEP,OM_CTFL) |
---|
94 | |
---|
95 | #define omTypeRealloc(o_addr,type,addr,size) addr=(type)_omDebugRealloc(o_addr,NULL,(void*)(size),_OM_FKEEP,OM_FSIZE|_OM_FKEEP,OM_CTFL) |
---|
96 | #define omTypeRealloc0(o_addr,type,addr,size) addr=(type)_omDebugRealloc(o_addr,NULL,(void*)(size),_OM_FKEEP,OM_FSIZE|OM_FZERO|_OM_FKEEP,OM_CTFL) |
---|
97 | #define omRealloc(addr,size) _omDebugRealloc(addr,NULL,(void*)(size),_OM_FKEEP,OM_FSIZE,OM_CTFL) |
---|
98 | #define omRealloc0(addr,size) _omDebugRealloc(addr,NULL,(void*)(size),_OM_FKEEP,OM_FSIZE|OM_FZERO,OM_CTFL) |
---|
99 | |
---|
100 | #define omreallocSize(addr,o_size,size) _omDebugRealloc(addr,(void*)(o_size),(void*)(size),OM_FSIZE|OM_FSLOPPY|_OM_FKEEP,OM_FSIZE|OM_FSLOPPY|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
101 | #define omrealloc0Size(addr,o_size,size)_omDebugRealloc(addr,(void*)(o_size),(void*)(size),OM_FSIZE|OM_FSLOPPY|_OM_FKEEP,OM_FSIZE|OM_FZERO|OM_FSLOPPY|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
102 | #define omrealloc(addr,size) _omDebugRealloc(addr,NULL,(void*)(size),OM_FSLOPPY|_OM_FKEEP,OM_FSIZE|OM_FSLOPPY|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
103 | #define omrealloc0(addr,size) _omDebugRealloc(addr,NULL,(void*)(size),OM_FSLOPPY|_OM_FKEEP,OM_FSIZE|OM_FZERO|OM_FSLOPPY|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
104 | |
---|
105 | #else |
---|
106 | #define omTypeReallocBin(o_addr,o_bin,type,addr,bin) __omTypeReallocBin(o_addr,o_bin,type,addr,bin) |
---|
107 | #define omTypeRealloc0Bin(o_addr,o_bin,type,addr,bin) __omTypeRealloc0Bin(o_addr,o_bin,type,addr,bin) |
---|
108 | #define omReallocBin(o_addr,o_bin,bin) _omReallocBin(o_addr,o_bin,bin) |
---|
109 | #define omRealloc0Bin(o_addr,o_bin,bin) _omRealloc0Bin(o_addr,o_bin,bin) |
---|
110 | |
---|
111 | #define omTypeReallocSize(o_addr,o_size,type,addr,size) __omTypeReallocSize(o_addr,o_size,type,addr,size) |
---|
112 | #define omTypeRealloc0Size(o_addr,o_size,type,addr,size) __omTypeRealloc0Size(o_addr,o_size,type,addr,size) |
---|
113 | #define omReallocSize(addr,o_size,size) _omReallocSize(addr,o_size,size) |
---|
114 | #define omRealloc0Size(addr,o_size,size) _omRealloc0Size(addr,o_size,size) |
---|
115 | |
---|
116 | #define omTypeRealloc(o_addr,type,addr,size) __omTypeRealloc(o_addr,type,addr,size) |
---|
117 | #define omTypeRealloc0(o_addr,type,addr,size) __omTypeRealloc0(o_addr,type,addr,size) |
---|
118 | #define omRealloc(addr,size) _omRealloc(addr,size) |
---|
119 | #define omRealloc0(addr,size) _omRealloc0(addr,size) |
---|
120 | |
---|
121 | #define omreallocSize(addr,o_size,size) _omreallocSize(addr,o_size,size) |
---|
122 | #define omrealloc0Size(addr,o_size,size)_omrealloc0Size(addr,o_size,size) |
---|
123 | #define omrealloc(addr,size) _omrealloc(addr, size) |
---|
124 | #define omrealloc0(addr,size) _omrealloc0(addr, size) |
---|
125 | |
---|
126 | #endif |
---|
127 | |
---|
128 | #if !defined(OM_T_FREE1) |
---|
129 | #define omFreeBinAddr(addr) _omDebugFree(addr,NULL,OM_FBINADDR|_OM_FKEEP,OM_CFL) |
---|
130 | #define omFreeBin(addr,bin) _omDebugFree(addr,bin,OM_FBIN|_OM_FKEEP,OM_CFL) |
---|
131 | #else |
---|
132 | #define omFreeBinAddr(addr) __omFreeBinAddr(addr) |
---|
133 | #define omFreeBin(addr,bin) __omFreeBinAddr(addr) |
---|
134 | #endif |
---|
135 | |
---|
136 | #if !defined(OM_T_FREE2) |
---|
137 | #define omFreeSize(addr,size) _omDebugFree(addr,(void*)(size),OM_FSIZE|_OM_FKEEP,OM_CFL) |
---|
138 | #define omfreeSize(addr,size) _omDebugFree(addr,(void*)(size),OM_FSIZE|OM_FSLOPPY|_OM_FKEEP,OM_CFL) |
---|
139 | #else |
---|
140 | #define omFreeSize(addr,size) __omFreeSize(addr,size) |
---|
141 | #define omfreeSize(addr,size) do {if (addr && size) omFreeSize(addr, size);} while (0) |
---|
142 | #endif |
---|
143 | |
---|
144 | #if !defined(OM_T_FREE3) |
---|
145 | #define omFree(addr) _omDebugFree(addr,0,0,OM_CFL) |
---|
146 | #define omfree(addr) _omDebugFree(addr,NULL,OM_FSLOPPY|_OM_FKEEP,OM_CFL) |
---|
147 | #else |
---|
148 | #define omFree(addr) __omFree(addr) |
---|
149 | #define omfree(addr) do {if (addr) omFree(addr);} while (0) |
---|
150 | #endif |
---|
151 | |
---|
152 | #if !defined(OM_T_STR) |
---|
153 | #define omStrDup(s) _omDebugStrDup(s,OM_TFL) |
---|
154 | #define omMemDup(addr) _omDebugMemDup(addr,_OM_FKEEP,OM_CTFL) |
---|
155 | #else |
---|
156 | #define omStrDup(s) _omStrDup(s) |
---|
157 | #define omMemDup(s) _omMemDup(s) |
---|
158 | #endif |
---|
159 | |
---|
160 | #define omDebugBinAddr(addr) _omDebugAddr(addr,NULL,OM_FBINADDR,OM_CFL) |
---|
161 | #define omDebugAddrBin(addr, bin) _omDebugAddr(addr,bin,OM_FBIN,OM_CFL) |
---|
162 | #define omDebugBinAddrSize(addr, size) _omDebugAddr(addr,(void*)(size),OM_FBINADDR|OM_FSIZE,OM_CFL) |
---|
163 | #define omDebugAddrSize(addr,size) _omDebugAddr(addr,(void*)(size),OM_FSIZE,OM_CFL) |
---|
164 | #define omDebugAddr(addr) _omDebugAddr(addr,NULL, 0, OM_CFL) |
---|
165 | #define omdebugAddrSize(addr,size) _omDebugAddr(addr,(void*)(size),OM_FSIZE|OM_FSLOPPY,OM_CFL) |
---|
166 | #define omdebugAddr(addr) _omDebugAddr(addr,NULL, OM_FSLOPPY, OM_CFL) |
---|
167 | #define omDebugBin(bin) _omDebugBin(bin,OM_CFL) |
---|
168 | #define omDebugMemory() _omDebugMemory(OM_CFL) |
---|
169 | #define omDebugIf(cond, statement) do { if (cond) {statement;}} while (0) |
---|
170 | |
---|
171 | #if OM_CHECK > 0 |
---|
172 | #define omCheckBinAddr omDebugBinAddr |
---|
173 | #define omCheckAddrBin omDebugAddrBin |
---|
174 | #define omCheckBinAddrSize omDebugBinAddrSize |
---|
175 | #define omCheckAddrSize omDebugAddrSize |
---|
176 | #define omCheckAddr omDebugAddr |
---|
177 | #define omcheckAddrSize omdebugAddrSize |
---|
178 | #define omcheckAddr omdebugAddr |
---|
179 | #define omCheckBin omDebugBin |
---|
180 | #define omCheckMemory omDebugMemory |
---|
181 | #define omCheckIf omDebugIf |
---|
182 | #endif /* OM_CHECK > 0 */ |
---|
183 | |
---|
184 | |
---|
185 | #ifdef OM_ALIGNMENT_NEEDS_WORK |
---|
186 | |
---|
187 | #define omTypeAllocAligned(type,addr,size) addr=(type)_omDebugAlloc((void*)(size),OM_FSIZE|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
188 | #define omTypeAlloc0Aligned(type,addr,size) addr=(type)_omDebugAlloc((void*)(size),OM_FSIZE|OM_FZERO|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
189 | #define omAllocAligned(size) _omDebugAlloc((void*)(size),OM_FSIZE|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
190 | #define omAlloc0Aligned(size) _omDebugAlloc((void*)(size),OM_FSIZE|OM_FZERO|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
191 | |
---|
192 | #define omTypeReallocAlignedSize(o_addr,o_size,type,addr,size) addr=(type)_omDebugRealloc(o_addr,(void*)(o_size),(void*)(size),OM_FSIZE|_OM_FKEEP,OM_FSIZE|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
193 | #define omTypeRealloc0AlignedSize(o_addr,o_size,type,addr,size) addr=(type)_omDebugRealloc(o_addr,(void*)(o_size),(void*)(size),OM_FSIZE|_OM_FKEEP,OM_FSIZE|OM_FZERO|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
194 | #define omReallocAlignedSize(addr,o_size,size) _omDebugRealloc(addr,(void*)(o_size),(void*)(size),OM_FSIZE|_OM_FKEEP,OM_FSIZE|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
195 | #define omRealloc0AlignedSize(addr,o_size,size) _omDebugRealloc(addr,(void*)(o_size),(void*)(size),OM_FSIZE|_OM_FKEEP,OM_FSIZE|OM_FZERO|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
196 | |
---|
197 | #define omTypeReallocAligned(o_addr,type,addr,size) addr=(type)_omDebugRealloc(o_addr,NULL,(void*)(size),_OM_FKEEP,OM_FSIZE|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
198 | #define omTypeRealloc0Aligned(o_addr,type,addr,size) addr=(type)_omDebugRealloc(o_addr,NULL,(void*)(size),_OM_FKEEP,OM_FSIZE|OM_FZERO|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
199 | #define omReallocAligned(addr,size) _omDebugRealloc(addr,NULL,(void*)(size),0,OM_FSIZE|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
200 | #define omRealloc0Aligned(addr,size) _omDebugRealloc(addr,NULL,(void*)(size),0,OM_FSIZE|OM_FZERO|OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
201 | |
---|
202 | #define omMemDupAligned(addr) _omDebugMemDup(addr,OM_FALIGN|_OM_FKEEP,OM_CTFL) |
---|
203 | |
---|
204 | #define omDebugBinAddrAligned(addr) _omDebugAddr(addr,NULL,OM_FBINADDR|OM_FALIGN,OM_CFL) |
---|
205 | #define omDebugAddrAlignedBin(addr, bin) _omDebugAddr(addr,bin,OM_FBIN|OM_FALIGN,OM_CFL) |
---|
206 | #define omDebugAddrAlignedSize(addr,size) _omDebugAddr(addr,(void*)(size),OM_FSIZE|OM_FALIGN,OM_CFL) |
---|
207 | #define omDebugAddrAligned(addr) _omDebugAddr(addr,NULL, OM_FALIGN, OM_CFL) |
---|
208 | #define omdebugAddrAlignedSize(addr,size) _omDebugAddr(addr,(void*)(size),OM_FSIZE|OM_FSLOPPY|OM_FALIGN,OM_CFL) |
---|
209 | #define omdebugAddrAligned(addr) _omDebugAddr(addr,NULL, OM_FSLOPPY|OM_FALIGN, OM_CFL) |
---|
210 | |
---|
211 | #if OM_CHECK > 0 |
---|
212 | #define omCheckBinAddrAligned omDebugBinAddrAligned |
---|
213 | #define omCheckAddrAlignedBin omDebugAddrAlignedBin |
---|
214 | #define omCheckAddrAlignedSize omDebugAddrAlignedSize |
---|
215 | #define omCheckAddrAligned omDebugAddrAligned |
---|
216 | #define omcheckAddrAlignedSize omdebugAddrAlignedSize |
---|
217 | #define omcheckAddrAligned omdebugAddrAligned |
---|
218 | #endif |
---|
219 | #endif /* OM_ALIGNMENT_NEEDS_WORK */ |
---|
220 | |
---|
221 | #elif !defined(OM_EMULATE_OMALLOC) |
---|
222 | /******************************************************************* |
---|
223 | * |
---|
224 | * Alloc/Free -- the real thing |
---|
225 | * |
---|
226 | *******************************************************************/ |
---|
227 | #define omTypeAllocBin(type,addr,bin) __omTypeAllocBin(type,addr,bin) |
---|
228 | #define omTypeAlloc0Bin(type,addr,bin) __omTypeAlloc0Bin(type,addr,bin) |
---|
229 | #define omAllocBin(bin) _omAllocBin(bin) |
---|
230 | #define omAlloc0Bin(bin) _omAlloc0Bin(bin) |
---|
231 | |
---|
232 | #define omTypeAlloc(type,addr,size) __omTypeAlloc(type,addr,size) |
---|
233 | #define omTypeAlloc0(type,addr,size) __omTypeAlloc0(type,addr,size) |
---|
234 | #define omAlloc(size) _omAlloc(size) |
---|
235 | #define omAlloc0(size) _omAlloc0(size) |
---|
236 | |
---|
237 | #define omTypeReallocBin(o_addr,o_bin,type,addr,bin) __omTypeReallocBin(o_addr,o_bin,type,addr,bin) |
---|
238 | #define omTypeRealloc0Bin(o_addr,o_bin,type,addr,bin) __omTypeRealloc0Bin(o_addr,o_bin,type,addr,bin) |
---|
239 | #define omReallocBin(o_addr,o_bin,bin) _omReallocBin(o_addr,o_bin,bin) |
---|
240 | #define omRealloc0Bin(o_addr,o_bin,bin) _omRealloc0Bin(o_addr,o_bin,bin) |
---|
241 | |
---|
242 | #define omTypeReallocSize(o_addr,o_size,type,addr,size) __omTypeReallocSize(o_addr,o_size,type,addr,size) |
---|
243 | #define omTypeRealloc0Size(o_addr,o_size,type,addr,size) __omTypeRealloc0Size(o_addr,o_size,type,addr,size) |
---|
244 | #define omReallocSize(addr,o_size,size) _omReallocSize(addr,o_size,size) |
---|
245 | #define omRealloc0Size(addr,o_size,size) _omRealloc0Size(addr,o_size,size) |
---|
246 | |
---|
247 | #define omTypeRealloc(o_addr,type,addr,size) __omTypeRealloc(o_addr,type,addr,size) |
---|
248 | #define omTypeRealloc0(o_addr,type,addr,size) __omTypeRealloc0(o_addr,type,addr,size) |
---|
249 | #define omRealloc(addr,size) _omRealloc(addr,size) |
---|
250 | #define omRealloc0(addr,size) _omRealloc0(addr,size) |
---|
251 | |
---|
252 | #define omalloc(size) _omalloc(size) |
---|
253 | #define omalloc0(size) _omalloc0(size) |
---|
254 | #define omcalloc(n,size)_omalloc0(n*size) |
---|
255 | |
---|
256 | #define omreallocSize(addr,o_size,size) _omreallocSize(addr,o_size,size) |
---|
257 | #define omrealloc0Size(addr,o_size,size)_omrealloc0Size(addr,o_size,size) |
---|
258 | #define omrealloc(addr,size) _omrealloc(addr, size) |
---|
259 | #define omrealloc0(addr,size) _omrealloc0(addr, size) |
---|
260 | |
---|
261 | #define omfreeSize(addr,size) do {if (addr && size) omFreeSize(addr, size);} while (0) |
---|
262 | #define omfree(addr) do {if (addr) omFree(addr);} while (0) |
---|
263 | |
---|
264 | #ifdef OM_ALIGNMENT_NEEDS_WORK |
---|
265 | #define omTypeAllocAligned(type,addr,size) __omTypeAllocAligned(type,addr,size) |
---|
266 | #define omTypeAlloc0Aligned(type,addr,size) __omTypeAlloc0Aligned(type,addr,size) |
---|
267 | #define omAllocAligned(size) _omAllocAligned(size) |
---|
268 | #define omAlloc0Aligned(size) _omAlloc0Aligned(size) |
---|
269 | |
---|
270 | #define omTypeReallocAlignedSize(o_addr,o_size,type,addr,size) __omTypeReallocAlignedSize(o_addr,o_size,type,addr,size) |
---|
271 | #define omTypeRealloc0AlignedSize(o_addr,o_size,type,addr,size) __omTypeRealloc0AlignedSize(o_addr,o_size,type,addr,size) |
---|
272 | #define omReallocAlignedSize(addr,o_size,size) _omReallocAlignedSize(addr,o_size,size) |
---|
273 | #define omRealloc0AlignedSize(addr,o_size,size) _omRealloc0AlignedSize(addr,o_size,size) |
---|
274 | |
---|
275 | #define omTypeReallocAligned(o_addr,type,addr,size) __omTypeReallocAligned(o_addr,type,addr,size) |
---|
276 | #define omTypeRealloc0Aligned(o_addr,type,addr,size) __omTypeRealloc0Aligned(o_addr,type,addr,size) |
---|
277 | #define omReallocAligned(addr,size) _omReallocAligned(addr,size) |
---|
278 | #define omRealloc0Aligned(addr,size) _omRealloc0Aligned(addr,size) |
---|
279 | |
---|
280 | #define omMemDupAligned(addr) _omMemDupAligned(addr) |
---|
281 | #endif /* OM_ALIGNMENT_NEEDS_WORK */ |
---|
282 | |
---|
283 | #define omFreeBinAddr(addr) __omFreeBinAddr(addr) |
---|
284 | #define omFreeBin(addr,bin) __omFreeBinAddr(addr) |
---|
285 | #define omFreeSize(addr,size) __omFreeSize(addr,size) |
---|
286 | #define omFree(addr) __omFree(addr) |
---|
287 | |
---|
288 | #define omStrDup(s) _omStrDup(s) |
---|
289 | #define omMemDup(s) _omMemDup(s) |
---|
290 | |
---|
291 | |
---|
292 | |
---|
293 | #else /* OM_EMULATE_OMALLOC */ |
---|
294 | /******************************************************************* |
---|
295 | * |
---|
296 | * Emulation of omalloc's Alloc/Free interface |
---|
297 | * |
---|
298 | *******************************************************************/ |
---|
299 | |
---|
300 | #include "omMalloc.h" |
---|
301 | |
---|
302 | extern void* omEmulateCalloc(size_t size); |
---|
303 | extern void* omEmulateRealloc0Size(void* o_addr, size_t o_size, size_t n_size); |
---|
304 | extern void* omEmulateRealloc0(void* o_addr, size_t n_size); |
---|
305 | |
---|
306 | #define omTypeAllocBin(type,addr,bin) addr=(type) OM_MALLOC_MALLOC(bin->sizeW << LOG_SIZEOF_LONG) |
---|
307 | #define omTypeAlloc0Bin(type,addr,bin) addr=(type) omEmulateAlloc0(bin->sizeW << LOG_SIZEOF_LONG) |
---|
308 | #define omAllocBin(bin) OM_MALLOC_MALLOC(bin->sizeW << LOG_SIZEOF_LONG) |
---|
309 | #define omAlloc0Bin(bin) omEmulateAlloc0(bin->sizeW << LOG_SIZEOF_LONG) |
---|
310 | |
---|
311 | #define omTypeAlloc(type,addr,size) addr=(type) OM_MALLOC_MALLOC(size) |
---|
312 | #define omTypeAlloc0(type,addr,size) addr=(type) omEmulateAlloc0(size) |
---|
313 | #define omAlloc(size) OM_MALLOC_MALLOC(size) |
---|
314 | #define omAlloc0(size) omEmulateAlloc0(size) |
---|
315 | |
---|
316 | #define omTypeReallocBin(o_addr,o_bin,type,addr,bin) addr=(type)OM_MALLOC_REALLOC(o_addr,bin->sizeW << LOG_SIZEOF_LONG) |
---|
317 | #define omTypeRealloc0Bin(o_addr,o_bin,type,addr,bin) addr=(type)omEmulateRealloc0Size(o_addr,o_bin->sizeW << LOG_SIZEOF_LONG,bin->sizeW << LOG_SIZEOF_LONG) |
---|
318 | #define omReallocBin(o_addr,o_bin,bin) OM_MALLOC_REALLOC(o_addr,bin->sizeW << LOG_SIZEOF_LONG) |
---|
319 | #define omRealloc0Bin(o_addr,o_bin,bin) omEmulateRealloc0Size(o_addr,o_bin->sizeW << LOG_SIZEOF_LONG,bin->sizeW << LOG_SIZEOF_LONG) |
---|
320 | |
---|
321 | #define omTypeReallocSize(o_addr,o_size,type,addr,size) addr=(type)OM_MALLOC_REALLOC(o_addr,size) |
---|
322 | #define omTypeRealloc0Size(o_addr,o_size,type,addr,size) addr=(type)omEmulateRealloc0Size(o_addr,o_size,size) |
---|
323 | #define omReallocSize(addr,o_size,size) OM_MALLOC_REALLOC(addr,size) |
---|
324 | #define omRealloc0Size(addr,o_size,size) omEmulateRealloc0Size(addr,o_size,size) |
---|
325 | |
---|
326 | #define omTypeRealloc(o_addr,type,addr,size) addr=(type)OM_MALLOC_REALLOC(o_addr,size) |
---|
327 | #define omTypeRealloc0(o_addr,type,addr,size) addr=(type)omEmulateRealloc0(o_addr,size) |
---|
328 | #define omRealloc(addr,size) OM_MALLOC_REALLOC(addr,size) |
---|
329 | #define omRealloc0(addr,size) omEmulateRealloc0(addr,size) |
---|
330 | |
---|
331 | #define omFreeBin(addr,bin) OM_MALLOC_FREE(addr) |
---|
332 | #define omFreeSize(addr,size) OM_MALLOC_FREE(addr) |
---|
333 | #define omFree(addr) OM_MALLOC_FREE(addr) |
---|
334 | #endif /* ! debug && ! the real thing */ |
---|
335 | |
---|
336 | |
---|
337 | /* define alignment stuff, if necessary */ |
---|
338 | #if !defined(omTypeAllocAligned) |
---|
339 | #define omTypeAllocAligned omTypeAlloc |
---|
340 | #define omTypeAlloc0Aligned omTypeAlloc0 |
---|
341 | #define omAllocAligned omAlloc |
---|
342 | #define omAlloc0Aligned omAlloc0 |
---|
343 | |
---|
344 | #define omTypeReallocAlignedSize omTypeReallocSize |
---|
345 | #define omTypeRealloc0AlignedSize omTypeRealloc0Size |
---|
346 | #define omReallocAlignedSize omReallocSize |
---|
347 | #define omRealloc0AlignedSize omRealloc0Size |
---|
348 | |
---|
349 | #define omTypeReallocAligned omTypeRealloc |
---|
350 | #define omTypeRealloc0Aligned omTypeRealloc0 |
---|
351 | #define omReallocAligned omRealloc |
---|
352 | #define omRealloc0Aligned omRealloc0 |
---|
353 | |
---|
354 | #define omMemDupAligned omMemDup |
---|
355 | #endif /* !defined(omTypeAllocAligned) */ |
---|
356 | |
---|
357 | #if !defined(omDebugAddrAlignedBin) |
---|
358 | #define omDebugBinAddrAligned omDebugBinAddr |
---|
359 | #define omDebugAddrAlignedBin omDebugAddrBin |
---|
360 | #define omDebugAddrAlignedSize omDebugAddrSize |
---|
361 | #define omDebugAddrAligned omDebugAddr |
---|
362 | #define omdebugAddrAlignedSize omdebugAddrSize |
---|
363 | #define omdebugAddrAligned omdebugAddr |
---|
364 | #endif /* !defined(omDebugAddrAlignedBin) */ |
---|
365 | |
---|
366 | #if !defined(omCheckAddrAlignedBin) |
---|
367 | #define omCheckBinAddrAligned omCheckBinAddr |
---|
368 | #define omCheckAddrAlignedBin omCheckAddrBin |
---|
369 | #define omCheckAddrAlignedSize omCheckAddrSize |
---|
370 | #define omCheckAddrAligned omCheckAddr |
---|
371 | #define omcheckAddrAlignedSize omcheckAddrSize |
---|
372 | #define omcheckAddrAligned omcheckAddr |
---|
373 | #endif /* !defined(omCheckAddrAlignedBin) */ |
---|
374 | |
---|
375 | /* define debug stuff, if necessary */ |
---|
376 | #if !defined(omDebugAddrBin) |
---|
377 | #define omDebugIf(cond, test) ((void) 0) |
---|
378 | #define omDebugBinAddr(addr) ((void) 0) |
---|
379 | #define omDebugAddrBin(addr,bin) ((void) 0) |
---|
380 | #define omDebugBinAddrSize(addr,size) ((void) 0) |
---|
381 | #define omDebugAddrSize(addr,size) ((void) 0) |
---|
382 | #define omDebugAddr(addr) ((void) 0) |
---|
383 | #define omdebugAddrSize(addr,size) ((void) 0) |
---|
384 | #define omdebugAddr(addr) ((void) 0) |
---|
385 | #define omDebugBin(bin) ((void) 0) |
---|
386 | #define omDebugMemory() ((void) 0) |
---|
387 | #endif /* !defined(omDebugAddrBin) */ |
---|
388 | |
---|
389 | /* define check stuff, if necessary */ |
---|
390 | #if !defined(omCheckAddrBin) |
---|
391 | #define omCheckIf(cond, test) ((void) 0) |
---|
392 | #define omCheckBinAddr(addr) ((void) 0) |
---|
393 | #define omCheckAddrBin(addr,bin) ((void) 0) |
---|
394 | #define omCheckBinAddrSize(addr,size) ((void) 0) |
---|
395 | #define omCheckAddrSize(addr,size) ((void) 0) |
---|
396 | #define omCheckAddr(addr) ((void) 0) |
---|
397 | #define omcheckAddrSize(addr,size) ((void) 0) |
---|
398 | #define omcheckAddr(addr) ((void) 0) |
---|
399 | #define omCheckBin(bin) ((void) 0) |
---|
400 | #define omCheckMemory() ((void) 0) |
---|
401 | #endif /* !defined(omCheckAddrBin) */ |
---|
402 | |
---|
403 | |
---|
404 | |
---|
405 | #if !defined(OM_NDEBUG) && !defined(OM_EMULATE_MALLOC) |
---|
406 | omError_t omTestAddrBin(void* addr, omBin bin, int check_level); |
---|
407 | omError_t omTestBinAddr(void* addr, int check_level); |
---|
408 | omError_t omTestBinAddrSize(void* addr, size_t size, int check_level); |
---|
409 | omError_t omTestAddrSize(void* addr, size_t size, int check_level); |
---|
410 | omError_t omTestAddr(void* addr, int check_level); |
---|
411 | omError_t omtestAddrSize(void* addr, size_t size, int check_level); |
---|
412 | omError_t omtestAddr(void* addr, int check_level); |
---|
413 | omError_t omTestAddrAlignedBin(void* addr, omBin bin, int check_level); |
---|
414 | omError_t omTestAddrAlignedSize(void* addr, size_t size, int check_level); |
---|
415 | omError_t omTestAddrAligned(void* addr, int check_level); |
---|
416 | omError_t omtestAddrAlignedSize(void* addr, size_t size, int check_level); |
---|
417 | omError_t omtestAddrAligned(void* addr, int check_level); |
---|
418 | omError_t omTestBin(omBin bin, int check_level); |
---|
419 | omError_t omTestMemory(int check_level); |
---|
420 | #define omTestIf(cond, statement) do { if (cond) {statement;}} while (0) |
---|
421 | |
---|
422 | #else |
---|
423 | |
---|
424 | #define omTestIf(cond, test) ((void) 0) |
---|
425 | #define omTestAddrBin(addr,bin,l) ((void) 0) |
---|
426 | #define omTestBinAddr(addr,l) ((void) 0) |
---|
427 | #define omTestBinAddrSize(addr,size,l) ((void) 0) |
---|
428 | #define omTestAddrSize(addr,size,l) ((void) 0) |
---|
429 | #define omTestAddr(addr,l) ((void) 0) |
---|
430 | #define omtestAddrSize(addr,size,l) ((void) 0) |
---|
431 | #define omtestAddr(addr,l) ((void) 0) |
---|
432 | #define omTestAddrAlignedBin(addr,bin,l) ((void) 0) |
---|
433 | #define omTestAddrAlignedSize(addr,size,l) ((void) 0) |
---|
434 | #define omTestAddrAligned(addr,l) ((void) 0) |
---|
435 | #define omtestAddrAlignedSize(addr,size,l) ((void) 0) |
---|
436 | #define omtestAddrAligned(addr,l) ((void) 0) |
---|
437 | #define omTestBin(bin,l) ((void) 0) |
---|
438 | #define omTestMemory(l) ((void) 0) |
---|
439 | |
---|
440 | #endif |
---|
441 | |
---|
442 | #endif /* OM_ALLOC_DECL_H */ |
---|