14#include "omalloc/omConfig.h"
15#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
18 #elif defined(HAVE_MALLOC_MALLOC_H)
19 #include <malloc/malloc.h>
24 #if __cplusplus >= 201402L
27 #elif defined(__clang__)
30 #define REGISTER register
33 #define REGISTER register
89#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
92 {
long *d=(
long*)
malloc(
s+
sizeof(
long)); *d=
s;d++;
return d; }
97#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
100{
long *d=(
long*)
malloc(
s+
sizeof(
long)); *d=
s;d++;
return d; }
103{
void *d=
omAlloc(
s);memset(d,0,
s);
return d; }
105{
if (
s!=0) {
void *d=
omAlloc(
s);memset(d,0,
s);
return d;}
else return NULL; }
110#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
114 long *dd=(
long*)d; dd--; dd=(
long*)
realloc(dd,ns+
sizeof(
long));
115 *dd=ns+
sizeof(long);dd++;
return dd;
119#define omReallocAligned(A,B) omRealloc(A,B)
123#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
127 long *dd=(
long*)d; dd--; dd=(
long*)
realloc(dd,ns+
sizeof(
long));
128 *dd=ns+
sizeof(long);dd++;
return dd;
133#ifdef HAVE_MALLOC_USABLE_SIZE
134{
return malloc_usable_size(d); }
135#elif defined(HAVE_AMLLOC_SIZE)
136{
return malloc_size(d); }
138{
long *dd=(
long*)d; dd--;
return *dd;}
142#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
145{
if (d!=
NULL) {
long *dd=(
long*)d; dd--;
free(dd);}}
149#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
152{
long *dd=(
long*)d; dd--;
free(dd);}
157#ifdef HAVE_MALLOC_USABLE_SIZE
159 if (d!=
NULL) os=malloc_usable_size(d);
168 memset(n+(ns-os),0,ns-os);
171#elif defined(HAVE_MALLOC_SIZE)
173 if (d!=
NULL) os=malloc_size(d);
182 memset(n+(ns-os),0,ns-os);
191 if (ns>os) c=os;
else c=ns;
199#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
202{
if (d!=
NULL) {
long *dd=(
long*)d; dd--;
free(dd);}}
206{
size_t l=strlen(
s);
char *ns=(
char *)
omAlloc(
l+1);
210#ifdef HAVE_MALLOC_USABLE_SIZE
211{
size_t l=malloc_usable_size(
s);
216#elif defined(HAVE_MALLOC_SIZE)
217{
size_t l=malloc_size(
s);
223{
long *n;
long *d=(
long*)
s; d--;
224 n=(
long*)
malloc(*d+
sizeof(
long));
225 memcpy(n,d,(*d)+
sizeof(
long));
232#define omSizeWOfBin(bin_ptr) (((bin_ptr)+sizeof(long)-1)/sizeof(long))
269#define omSizeWOfAddr(P) (omSizeOfAddr(P)/sizeof(long))
271#define omTypeAllocBin(T,P,B) P=(T)omAlloc(B)
272#define omTypeAlloc(T,P,S) P=(T)omAlloc(S)
273#define omTypeAlloc0Bin(T,P,B) P=(T)omAlloc0(B)
274#define omAlloc0Aligned(S) omAlloc0(S)
275#define omAllocAligned(S) omAlloc(S)
276#define omAllocBin(B) omAlloc(B)
277#define omAllocBin0(B) omAlloc0(B)
278#define omAlloc0Bin(B) omAlloc0(B)
280#define omInitGetBackTrace()
281#define omUpdateInfo()
282#define omPrintStats(F)
283#define omPrintInfo(F)
284#define omPrintBinStats(F)
285#define omMarkMemoryAsStatic()
286#define omFreeBin(P,B) omFree(P)
287#define omfreeSize(P,S) omFreeSize(P,S)
288#define omFreeFunc omFree
289#define omFreeBinAddr(P) omFree(P)
290#define omrealloc(A,NS) omRealloc(A,NS)
291#define omreallocSize(A,OS,NS) omRealloc(A,NS)
292#define omRealloc0Size(A,OS,NS) omRealloc0(A,NS)
293#define omrealloc0Size(A,OS,NS) omRealloc0(A,NS)
294#define omMarkAsStaticAddr(A)
295#define omMemCpyW(A,B,S) memcpy(A,B,(S)<<2)
296#define omMemcpyW(A,B,S) memcpy(A,B,(S)<<2)
297#define omGetSpecBin(A) (A)
298#define omUnGetSpecBin(A) do {} while (0)
299#define memcpyW(A,B,C) memcpy(A,B,(C)*sizeof(long))
300#define omGetStickyBinOfBin(B) omGetSpecBin(B)
304#define omTypeReallocAlignedSize omTypeReallocSize
305#define omTypeRealloc0AlignedSize omTypeRealloc0Size
306#define omReallocAlignedSize omReallocSize
307#define omRealloc0AlignedSize omRealloc0Size
308#define omMemDupAligned omMemDup
309#define omCheckIf(cond, test) do {} while (0)
310#define omCheckBinAddr(addr) do {} while (0)
311#define omCheckAddrBin(addr,bin) do {} while (0)
312#define omCheckBinAddrSize(addr,size) do {} while (0)
313#define omCheckAddrSize(addr,size) do {} while (0)
314#define omCheckAddr(addr) do {} while (0)
315#define omcheckAddrSize(addr,size) do {} while (0)
316#define omcheckAddr(addr) do {} while (0)
317#define omCheckBin(bin) do {} while (0)
318#define omCheckMemory() do {} while (0)
319#define omPrintCurrentBackTraceMax(A,B) do {} while (0)
320#define omPrintUsedTrackAddrs(F,max) do {} while (0)
321#define omPrintCurrentBackTrace(F) do {} while (0)
322#define omPrintUsedAddrs(F,max) do {} while (0)
323#define omdebugAddrSize(A,B) do {} while (0)
324#define omPrintAddrInfo(A,B,C) do {} while (0)
325#define omIsBinPageAddr(A) (1)
326#define omTestBinAddrSize(A,B,C) (omError_NoError)
327#define omTestList(ptr, level) (omError_NoError)
328#define omInitRet_2_Info(argv0) do {} while (0)
329#define omMergeStickyBinIntoBin(A,B) do {} while (0)
336#undef OMALLOC_USES_MALLOC
338#define omMallocFunc omAlloc
339#define omReallocSizeFunc omReallocSize
340#define omFreeSizeFunc omFreeSize
const CanonicalForm int s
#define omFreeSize(addr, size)
#define omReallocSize(addr, o_size, size)
#define omRealloc(addr, size)
#define omRealloc0(addr, size)
void(* OutOfMemoryFunc)()
unsigned int PagesPerRegion
long CurrentBytesFromValloc
long CurrentBytesFromMalloc
static long omSizeOfAddr(void *d)
@ omError_MemoryCorrupted
@ omError_FreedAddrOrMemoryCorrupted
@ omError_SortedListError
@ omError_KeptAddrListCorrupted
@ omError_InvalidRangeAddr
@ omError_FalseAddrOrMemoryCorrupted
long AvailBytesFromValloc