 |
My Project
debian-1:4.1.2-p1+ds-2
|
Go to the documentation of this file.
14 #include "omalloc/omConfig.h"
15 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
20 #if __cplusplus >= 201402L
23 #elif defined(__clang__)
26 #define REGISTER register
29 #define REGISTER register
83 static inline void *
omalloc(
size_t s)
85 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
88 {
long *d=(
long*)
malloc(
s+
sizeof(
long)); *d=
s;d++;
return d; }
92 static inline void *
omAlloc(
size_t s)
93 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
96 {
long *d=(
long*)
malloc(
s+
sizeof(
long)); *d=
s;d++;
return d; }
101 {
if (
s!=0) {
void *d=
omAlloc(
s);memset(d,0,
s);
return d;}
else return NULL; }
103 static inline void *
omRealloc(
void *d,
size_t ns)
106 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
110 long *dd=(
long*)d; dd--; dd=(
long*)
realloc(dd,ns+
sizeof(
long));
111 *dd=ns+
sizeof(long);dd++;
return dd;
115 #define omReallocAligned(A,B) omRealloc(A,B)
119 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
123 long *dd=(
long*)d; dd--; dd=(
long*)
realloc(dd,ns+
sizeof(
long));
124 *dd=ns+
sizeof(long);dd++;
return dd;
129 #ifdef HAVE_MALLOC_USABLE_SIZE
130 {
return malloc_usable_size(d); }
131 #elif defined(HAVE_AMLLOC_SIZE)
132 {
return malloc_size(d); }
134 {
long *dd=(
long*)d; dd--;
return *dd;}
137 static inline void omFree(
void *d)
138 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
141 {
if (d!=
NULL) {
long *dd=(
long*)d; dd--;
free(dd);}}
144 static inline void *
omRealloc0(
void *d,
size_t ns)
146 #ifdef HAVE_MALLOC_USABLE_SIZE
148 if (d!=
NULL) os=malloc_usable_size(d);
157 memset(n+(ns-os),0,ns-os);
160 #elif defined(HAVE_MALLOC_SIZE)
162 if (d!=
NULL) os=malloc_size(d);
171 memset(n+(ns-os),0,ns-os);
180 if (ns>os) c=os;
else c=ns;
188 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
191 {
if (d!=
NULL) {
long *dd=(
long*)d; dd--;
free(dd);}}
194 static inline char *
omStrDup(
const char *
s)
195 {
size_t l=strlen(
s);
char *ns=(
char *)
omAlloc(
l+1);
199 #ifdef HAVE_MALLOC_USABLE_SIZE
200 {
size_t l=malloc_usable_size(
s);
205 #elif defined(HAVE_MALLOC_SIZE)
206 {
size_t l=malloc_size(
s);
212 {
long *n;
long *d=(
long*)
s; d--;
213 n=(
long*)
malloc(*d+
sizeof(
long));
214 memcpy(n,d,(*d)+
sizeof(
long));
221 #define omSizeWOfBin(bin_ptr) (((bin_ptr)+sizeof(long)-1)/sizeof(long))
258 #define omSizeWOfAddr(P) (omSizeOfAddr(P)/sizeof(long))
260 #define omTypeAllocBin(T,P,B) P=(T)omAlloc(B)
261 #define omTypeAlloc(T,P,S) P=(T)omAlloc(S)
262 #define omTypeAlloc0Bin(T,P,B) P=(T)omAlloc0(B)
263 #define omAlloc0Aligned(S) omAlloc0(S)
264 #define omAllocAligned(S) omAlloc(S)
265 #define omAllocBin(B) omAlloc(B)
266 #define omAllocBin0(B) omAlloc0(B)
267 #define omAlloc0Bin(B) omAlloc0(B)
269 #define omInitGetBackTrace()
270 #define omUpdateInfo()
271 #define omPrintStats(F)
272 #define omPrintInfo(F)
273 #define omPrintBinStats(F)
274 #define omMarkMemoryAsStatic()
275 #define omfree(P) omFree(P)
276 #define omFreeBin(P,B) omFree(P)
277 #define omfreeSize(P,S) omFreeSize(P,S)
278 #define omFreeFunc omFree
279 #define omFreeBinAddr(P) omFree(P)
280 #define omrealloc(A,NS) omRealloc(A,NS)
281 #define omreallocSize(A,OS,NS) omRealloc(A,NS)
282 #define omRealloc0Size(A,OS,NS) omRealloc0(A,NS)
283 #define omrealloc0Size(A,OS,NS) omRealloc(A,NS)
284 #define omMarkAsStaticAddr(A)
285 #define omMemCpyW(A,B,S) memcpy(A,B,(S)<<2)
286 #define omMemcpyW(A,B,S) memcpy(A,B,(S)<<2)
287 #define omGetSpecBin(A) (A)
288 #define omUnGetSpecBin(A) do {} while (0)
289 #define memcpyW(A,B,C) memcpy(A,B,(C)*sizeof(long))
290 #define omGetStickyBinOfBin(B) omGetSpecBin(B)
294 #define omTypeReallocAlignedSize omTypeReallocSize
295 #define omTypeRealloc0AlignedSize omTypeRealloc0Size
296 #define omReallocAlignedSize omReallocSize
297 #define omRealloc0AlignedSize omRealloc0Size
298 #define omMemDupAligned omMemDup
299 #define omCheckIf(cond, test) do {} while (0)
300 #define omCheckBinAddr(addr) do {} while (0)
301 #define omCheckAddrBin(addr,bin) do {} while (0)
302 #define omCheckBinAddrSize(addr,size) do {} while (0)
303 #define omCheckAddrSize(addr,size) do {} while (0)
304 #define omCheckAddr(addr) do {} while (0)
305 #define omcheckAddrSize(addr,size) do {} while (0)
306 #define omcheckAddr(addr) do {} while (0)
307 #define omCheckBin(bin) do {} while (0)
308 #define omCheckMemory() do {} while (0)
309 #define omPrintCurrentBackTraceMax(A,B) do {} while (0)
310 #define omPrintUsedTrackAddrs(F,max) do {} while (0)
311 #define omPrintCurrentBackTrace(F) do {} while (0)
312 #define omPrintUsedAddrs(F,max) do {} while (0)
313 #define omdebugAddrSize(A,B) do {} while (0)
314 #define omPrintAddrInfo(A,B,C) do {} while (0)
315 #define omIsBinPageAddr(A) (1)
316 #define omTestBinAddrSize(A,B,C) (omError_NoError)
317 #define omTestList(ptr, level) (omError_NoError)
318 #define omInitRet_2_Info(argv0) do {} while (0)
319 #define omMergeStickyBinIntoBin(A,B) do {} while (0)
326 #undef OMALLOC_USES_MALLOC
328 #define omMallocFunc omAlloc
329 #define omReallocSizeFunc omReallocSize
330 #define omFreeSizeFunc omFreeSize
static void * omAlloc0(size_t s)
static void * omReallocSize(void *d, __attribute__((unused)) size_t os, size_t ns)
static void * omMemDup(void *s)
unsigned int PagesPerRegion
long AvailBytesFromValloc
static void * omRealloc(void *d, size_t ns)
long CurrentBytesFromValloc
void * malloc(size_t size)
static void * omRealloc0(void *d, size_t ns)
static void * omalloc(size_t s)
static char * omStrDup(const char *s)
static void * omalloc0(size_t s)
static void omFree(void *d)
static long omSizeOfAddr(void *d)
static void omFreeSize(void *d, __attribute__((unused)) size_t s)
const CanonicalForm int s
long CurrentBytesFromMalloc
void(* OutOfMemoryFunc)()
static void * omAlloc(size_t s)