28 #ifndef __RTXMEMORY_H__ 29 #define __RTXMEMORY_H__ 41 #define RT_MH_DONTKEEPFREE 0x1 42 #define RT_MH_VALIDATEPTR 0x2 43 #define RT_MH_CHECKHEAP 0x4 44 #define RT_MH_TRACE 0x8 45 #define RT_MH_DIAG 0x10 46 #define RT_MH_DIAG_DEBUG 0x20 47 #define RT_MH_ZEROONFREE 0x40 48 #define RT_MH_ZEROARRAY 0x80 49 #define RT_MH_SYSALLOC 0x100 50 #define RT_MH_TRACE_FREELIST 0x200 55 #define OSRTMH_PROPID_DEFBLKSIZE 1 56 #define OSRTMH_PROPID_SETFLAGS 2 57 #define OSRTMH_PROPID_CLEARFLAGS 3 58 #define OSRTMH_PROPID_KEEPFREEUNITS 4 60 #define OSRTMH_PROPID_USER 10 62 #define OSRTXM_K_MEMBLKSIZ (4*1024) 77 #define OSRTALLOCTYPE(pctxt,type) \ 78 (type*) rtxMemHeapAlloc (&(pctxt)->pMemHeap, sizeof(type)) 86 #define OSRTALLOCTYPEZ(pctxt,type) \ 87 (type*) rtxMemHeapAllocZ (&(pctxt)->pMemHeap, sizeof(type)) 100 #define OSRTREALLOCARRAY(pctxt,pseqof,type) do {\ 101 if (sizeof(type)*(pseqof)->n < (pseqof)->n) return RTERR_NOMEM; \ 102 if (((pseqof)->elem = (type*) rtxMemHeapRealloc \ 103 (&(pctxt)->pMemHeap, (pseqof)->elem, sizeof(type)*(pseqof)->n)) == 0) \ 104 return RTERR_NOMEM; \ 108 #define OSCRTMALLOC0(nbytes) malloc(nbytes) 109 #define OSCRTFREE0(ptr) free(ptr) 113 extern EXTERNRT
OSCTXT g_ctxt;
115 #define OSCRTMALLOC0(nbytes) rtxMemAlloc(&g_ctxt,(nbytes)) 116 #define OSCRTFREE0(ptr) rtxMemFreePtr(&g_ctxt,(ptr)) 118 #define OSCRTMALLOC0(nbytes) (void*)0 119 #define OSCRTFREE0(ptr) (void*)0 124 #define OSCRTMALLOC rtxMemAlloc 125 #define OSCRTFREE rtxMemFreePtr 136 #if !defined(OSCDECL) 137 #if defined(_MSC_VER) || defined(__BORLANDC__) 138 #define OSCDECL __cdecl 144 EXTERNRT
void rtxMemHeapAddRef (
void** ppvMemHeap);
145 EXTERNRT
void* rtxMemHeapAlloc (
void** ppvMemHeap, OSSIZE nbytes);
146 EXTERNRT
void* rtxMemHeapAllocZ (
void** ppvMemHeap, OSSIZE nbytes);
147 EXTERNRT
void* rtxMemHeapSysAlloc (
void** ppvMemHeap, OSSIZE nbytes);
148 EXTERNRT
void* rtxMemHeapSysAllocZ (
void** ppvMemHeap, OSSIZE nbytes);
149 EXTERNRT
int rtxMemHeapCheckPtr (
void** ppvMemHeap,
const void* mem_p);
150 EXTERNRT
void rtxMemHeapFreeAll (
void** ppvMemHeap);
151 EXTERNRT
void rtxMemHeapFreePtr (
void** ppvMemHeap,
void* mem_p);
152 EXTERNRT
void rtxMemHeapSysFreePtr (
void** ppvMemHeap,
void* mem_p);
163 EXTERNRT
void* rtxMemHeapReallocStatic
164 (
void** ppvMemHeap,
void* mem_p, OSSIZE oldsize, OSSIZE newsize);
166 EXTERNRT
void* rtxMemHeapRealloc
167 (
void** ppvMemHeap,
void* mem_p, OSSIZE nbytes_);
169 EXTERNRT
void* rtxMemHeapSysRealloc
170 (
void** ppvMemHeap,
void* mem_p, OSSIZE nbytes_);
172 EXTERNRT
void rtxMemHeapRelease (
void** ppvMemHeap);
173 EXTERNRT
void rtxMemHeapReset (
void** ppvMemHeap);
174 EXTERNRT
void rtxMemHeapSetProperty (
void** ppvMemHeap,
175 OSUINT32 propId,
void* pProp);
177 EXTERNRT
void* rtxMemNewArray (OSSIZE nbytes);
178 EXTERNRT
void* rtxMemNewArrayZ (OSSIZE nbytes);
179 EXTERNRT
void rtxMemDeleteArray (
void* mem_p);
181 EXTERNRT
void* rtxMemHeapAutoPtrRef (
void** ppvMemHeap,
void* ptr);
182 EXTERNRT
int rtxMemHeapAutoPtrUnref (
void** ppvMemHeap,
void* ptr);
183 EXTERNRT
int rtxMemHeapAutoPtrGetRefCount (
void** ppvMemHeap,
void* mem_p);
185 EXTERNRT
void rtxMemHeapInvalidPtrHook (
void** ppvMemHeap,
const void* mem_p);
187 EXTERNRT
void rtxMemHeapCheck (
void **ppvMemHeap,
const char* file,
int line);
223 OSMallocFunc malloc_func,
224 OSReallocFunc realloc_func,
225 OSFreeFunc free_func);
245 (
void **ppvMemHeap,
void* pmem, OSSIZE memsize) ;
264 (
void** ppvMemHeap,
void* pmem, OSSIZE memsize);
266 #if !defined(_ARMTCC) && !defined(__SYMBIAN32__) 283 OSReallocFunc realloc_func,
284 OSFreeFunc free_func);
288 EXTERNRT
void rtxMemFreeOpenSeqExt
299 #ifndef __SYMBIAN32__ 335 EXTERNRT OSBOOL
rtxMemIsZero (
const void* pmem, OSSIZE memsiz);
338 EXTERNRT
void rtxMemSetStaticBuf (
void* memHeapBuf, OSUINT32 blkSize);
350 #define rtxMemAlloc(pctxt,nbytes) \ 351 rtxMemHeapAlloc(&(pctxt)->pMemHeap,nbytes) 363 #define rtxMemSysAlloc(pctxt,nbytes) \ 364 rtxMemHeapSysAlloc(&(pctxt)->pMemHeap,nbytes) 375 #define rtxMemAllocZ(pctxt,nbytes) \ 376 rtxMemHeapAllocZ(&(pctxt)->pMemHeap,nbytes) 391 #define rtxMemSysAllocZ(pctxt,nbytes) \ 392 rtxMemHeapSysAllocZ(&(pctxt)->pMemHeap,nbytes) 409 #define rtxMemRealloc(pctxt,mem_p,nbytes) \ 410 rtxMemHeapRealloc(&(pctxt)->pMemHeap, (void*)mem_p, nbytes) 428 #define rtxMemSysRealloc(pctxt,mem_p,nbytes) \ 429 rtxMemHeapSysRealloc(&(pctxt)->pMemHeap,(void*)mem_p,nbytes) 442 #define rtxMemFreePtr(pctxt,mem_p) \ 443 rtxMemHeapFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 455 #define rtxMemSysFreePtr(pctxt,mem_p) \ 456 rtxMemHeapSysFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 493 #define rtxMemAllocType(pctxt,ctype) \ 494 (ctype*)rtxMemHeapAlloc(&(pctxt)->pMemHeap,sizeof(ctype)) 509 #define rtxMemSysAllocType(pctxt,ctype) \ 510 (ctype*)rtxMemHeapSysAlloc(&(pctxt)->pMemHeap,sizeof(ctype)) 521 #define rtxMemAllocTypeZ(pctxt,ctype) \ 522 (ctype*)rtxMemHeapAllocZ(&(pctxt)->pMemHeap,sizeof(ctype)) 537 #define rtxMemSysAllocTypeZ(pctxt,ctype) \ 538 (ctype*)rtxMemHeapSysAllocZ(&(pctxt)->pMemHeap,sizeof(ctype)) 551 #define rtxMemFreeType(pctxt,mem_p) \ 552 rtxMemHeapFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 565 #define rtxMemSysFreeType(pctxt,mem_p) \ 566 rtxMemHeapSysFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 577 #define rtxMemAllocArray(pctxt,n,type) \ 578 (type*)rtxMemAllocArray2 (pctxt, n, sizeof(type), 0) 580 EXTERNRT
void* rtxMemAllocArray2
581 (
OSCTXT* pctxt, OSSIZE numElements, OSSIZE typeSize, OSUINT32 flags);
596 #define rtxMemSysAllocArray(pctxt,n,type) \ 597 (type*)rtxMemAllocArray2 (pctxt, n, sizeof(type), RT_MH_SYSALLOC) 608 #define rtxMemAllocArrayZ(pctxt,n,type) \ 609 (type*)rtxMemAllocArray2 (pctxt, n, sizeof(type), RT_MH_ZEROARRAY) 622 #define rtxMemFreeArray(pctxt,mem_p) \ 623 rtxMemHeapFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 636 #define rtxMemSysFreeArray(pctxt,mem_p) \ 637 rtxMemHeapSysFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 653 #define rtxMemReallocArray(pctxt,mem_p,n,type) \ 654 (type*)rtxMemHeapRealloc(&(pctxt)->pMemHeap, (void*)mem_p, sizeof(type)*n) 669 #define rtxMemNewAutoPtr(pctxt,nbytes) \ 670 rtxMemHeapAlloc(&(pctxt)->pMemHeap, nbytes) 680 #define rtxMemAutoPtrRef(pctxt,ptr) \ 681 rtxMemHeapAutoPtrRef(&(pctxt)->pMemHeap, (void*)(ptr)) 693 #define rtxMemAutoPtrUnref(pctxt,ptr) \ 694 rtxMemHeapAutoPtrUnref(&(pctxt)->pMemHeap, (void*)(ptr)) 704 #define rtxMemAutoPtrGetRefCount(pctxt,ptr) \ 705 rtxMemHeapAutoPtrGetRefCount(&(pctxt)->pMemHeap, (void*)(ptr)) 715 #define rtxMemCheckPtr(pctxt,mem_p) \ 716 rtxMemHeapCheckPtr(&(pctxt)->pMemHeap, (void*)mem_p) 723 #define rtxMemCheck(pctxt) \ 724 rtxMemHeapCheck(&(pctxt)->pMemHeap, __FILE__, __LINE__) 731 #define rtxMemPrint(pctxt) \ 732 rtxMemHeapPrint(&(pctxt)->pMemHeap) 740 #define rtxMemPrintWithFree(pctxt) \ 741 rtxMemHeapPrintWithFree(&(pctxt)->pMemHeap) 750 #define rtxMemSetProperty(pctxt,propId,pProp) \ 751 rtxMemHeapSetProperty (&(pctxt)->pMemHeap, propId, pProp) OSUINT32 rtxMemGetDefBlkSize(OSVOIDARG)
OSUINT32 rtxMemHeapGetDefBlkSize(OSCTXT *pctxt)
Definition: rtxDList.h:64
OSBOOL rtxMemIsZero(const void *pmem, OSSIZE memsiz)
void rtxMemHeapPrintWithFree(void **ppvMemHeap)
void rtxMemHeapPrint(void **ppvMemHeap)
void rtxMemReset(OSCTXT *pctxt)
int rtxMemHeapConvertStatic(void **ppvMemHeap, void *pmem, OSSIZE memsize)
int rtxMemStaticHeapCreate(void **ppvMemHeap, void *pmem, OSSIZE memsize)
int rtxMemHeapCreateExt(void **ppvMemHeap, OSMallocFunc malloc_func, OSReallocFunc realloc_func, OSFreeFunc free_func)
void rtxMemSetAllocFuncs(OSMallocFunc malloc_func, OSReallocFunc realloc_func, OSFreeFunc free_func)
int rtxMemHeapCreate(void **ppvMemHeap)
OSBOOL rtxMemHeapIsEmpty(OSCTXT *pctxt)
void rtxMemSetDefBlkSize(OSUINT32 blkSize)
Definition: rtxContext.h:198
void rtxMemFree(OSCTXT *pctxt)