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);}}
150#ifdef HAVE_MALLOC_USABLE_SIZE
152 if (d!=
NULL) os=malloc_usable_size(d);
161 memset(n+(ns-os),0,ns-os);
164#elif defined(HAVE_MALLOC_SIZE)
166 if (d!=
NULL) os=malloc_size(d);
175 memset(n+(ns-os),0,ns-os);
184 if (ns>os) c=os;
else c=ns;
192#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE)
195{
if (d!=
NULL) {
long *dd=(
long*)d; dd--;
free(dd);}}
199{
size_t l=strlen(
s);
char *ns=(
char *)
omAlloc(
l+1);
203#ifdef HAVE_MALLOC_USABLE_SIZE
204{
size_t l=malloc_usable_size(
s);
209#elif defined(HAVE_MALLOC_SIZE)
210{
size_t l=malloc_size(
s);
216{
long *n;
long *d=(
long*)
s; d--;
217 n=(
long*)
malloc(*d+
sizeof(
long));
218 memcpy(n,d,(*d)+
sizeof(
long));
225#define omSizeWOfBin(bin_ptr) (((bin_ptr)+sizeof(long)-1)/sizeof(long))
262#define omSizeWOfAddr(P) (omSizeOfAddr(P)/sizeof(long))
264#define omTypeAllocBin(T,P,B) P=(T)omAlloc(B)
265#define omTypeAlloc(T,P,S) P=(T)omAlloc(S)
266#define omTypeAlloc0Bin(T,P,B) P=(T)omAlloc0(B)
267#define omAlloc0Aligned(S) omAlloc0(S)
268#define omAllocAligned(S) omAlloc(S)
269#define omAllocBin(B) omAlloc(B)
270#define omAllocBin0(B) omAlloc0(B)
271#define omAlloc0Bin(B) omAlloc0(B)
273#define omInitGetBackTrace()
274#define omUpdateInfo()
275#define omPrintStats(F)
276#define omPrintInfo(F)
277#define omPrintBinStats(F)
278#define omMarkMemoryAsStatic()
279#define omfree(P) omFree(P)
280#define omFreeBin(P,B) omFree(P)
281#define omfreeSize(P,S) omFreeSize(P,S)
282#define omFreeFunc omFree
283#define omFreeBinAddr(P) omFree(P)
284#define omrealloc(A,NS) omRealloc(A,NS)
285#define omreallocSize(A,OS,NS) omRealloc(A,NS)
286#define omRealloc0Size(A,OS,NS) omRealloc0(A,NS)
287#define omrealloc0Size(A,OS,NS) omRealloc0(A,NS)
288#define omMarkAsStaticAddr(A)
289#define omMemCpyW(A,B,S) memcpy(A,B,(S)<<2)
290#define omMemcpyW(A,B,S) memcpy(A,B,(S)<<2)
291#define omGetSpecBin(A) (A)
292#define omUnGetSpecBin(A) do {} while (0)
293#define memcpyW(A,B,C) memcpy(A,B,(C)*sizeof(long))
294#define omGetStickyBinOfBin(B) omGetSpecBin(B)
298#define omTypeReallocAlignedSize omTypeReallocSize
299#define omTypeRealloc0AlignedSize omTypeRealloc0Size
300#define omReallocAlignedSize omReallocSize
301#define omRealloc0AlignedSize omRealloc0Size
302#define omMemDupAligned omMemDup
303#define omCheckIf(cond, test) do {} while (0)
304#define omCheckBinAddr(addr) do {} while (0)
305#define omCheckAddrBin(addr,bin) do {} while (0)
306#define omCheckBinAddrSize(addr,size) do {} while (0)
307#define omCheckAddrSize(addr,size) do {} while (0)
308#define omCheckAddr(addr) do {} while (0)
309#define omcheckAddrSize(addr,size) do {} while (0)
310#define omcheckAddr(addr) do {} while (0)
311#define omCheckBin(bin) do {} while (0)
312#define omCheckMemory() do {} while (0)
313#define omPrintCurrentBackTraceMax(A,B) do {} while (0)
314#define omPrintUsedTrackAddrs(F,max) do {} while (0)
315#define omPrintCurrentBackTrace(F) do {} while (0)
316#define omPrintUsedAddrs(F,max) do {} while (0)
317#define omdebugAddrSize(A,B) do {} while (0)
318#define omPrintAddrInfo(A,B,C) do {} while (0)
319#define omIsBinPageAddr(A) (1)
320#define omTestBinAddrSize(A,B,C) (omError_NoError)
321#define omTestList(ptr, level) (omError_NoError)
322#define omInitRet_2_Info(argv0) do {} while (0)
323#define omMergeStickyBinIntoBin(A,B) do {} while (0)
330#undef OMALLOC_USES_MALLOC
332#define omMallocFunc omAlloc
333#define omReallocSizeFunc omReallocSize
334#define omFreeSizeFunc omFreeSize
const CanonicalForm int s
void * malloc(size_t size)
void(* OutOfMemoryFunc)()
unsigned int PagesPerRegion
static void * omRealloc0(void *d, size_t ns)
long CurrentBytesFromValloc
static void omFree(void *d)
long CurrentBytesFromMalloc
static void * omAlloc(size_t s)
static char * omStrDup(const char *s)
static void * omMemDup(void *s)
static void * omReallocSize(void *d, __attribute__((unused)) size_t os, size_t ns)
static void * omAlloc0(size_t s)
static void * omalloc(size_t s)
static void * omalloc0(size_t s)
static void omFreeSize(void *d, __attribute__((unused)) size_t s)
static long omSizeOfAddr(void *d)
@ omError_MemoryCorrupted
@ omError_FreedAddrOrMemoryCorrupted
@ omError_SortedListError
@ omError_KeptAddrListCorrupted
@ omError_InvalidRangeAddr
@ omError_FalseAddrOrMemoryCorrupted
long AvailBytesFromValloc
static void * omRealloc(void *d, size_t ns)