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 51 #define OSRTMH_PROPID_DEFBLKSIZE 1 52 #define OSRTMH_PROPID_SETFLAGS 2 53 #define OSRTMH_PROPID_CLEARFLAGS 3 54 #define OSRTMH_PROPID_KEEPFREEUNITS 4 56 #define OSRTMH_PROPID_USER 10 58 #define OSRTXM_K_MEMBLKSIZ (4*1024) 73 #define OSRTALLOCTYPE(pctxt,type) \ 74 (type*) rtxMemHeapAlloc (&(pctxt)->pMemHeap, sizeof(type)) 82 #define OSRTALLOCTYPEZ(pctxt,type) \ 83 (type*) rtxMemHeapAllocZ (&(pctxt)->pMemHeap, sizeof(type)) 96 #define OSRTREALLOCARRAY(pctxt,pseqof,type) do {\ 97 if (sizeof(type)*(pseqof)->n < (pseqof)->n) return RTERR_NOMEM; \ 98 if (((pseqof)->elem = (type*) rtxMemHeapRealloc \ 99 (&(pctxt)->pMemHeap, (pseqof)->elem, sizeof(type)*(pseqof)->n)) == 0) \ 100 return RTERR_NOMEM; \ 104 #define OSCRTMALLOC0(nbytes) malloc(nbytes) 105 #define OSCRTFREE0(ptr) free(ptr) 109 extern EXTERNRT
OSCTXT g_ctxt;
111 #define OSCRTMALLOC0(nbytes) rtxMemAlloc(&g_ctxt,(nbytes)) 112 #define OSCRTFREE0(ptr) rtxMemFreePtr(&g_ctxt,(ptr)) 114 #define OSCRTMALLOC0(nbytes) (void*)0 115 #define OSCRTFREE0(ptr) (void*)0 120 #define OSCRTMALLOC rtxMemAlloc 121 #define OSCRTFREE rtxMemFreePtr 132 #if !defined(OSCDECL) 133 #if defined(_MSC_VER) || defined(__BORLANDC__) 134 #define OSCDECL __cdecl 140 EXTERNRT
void rtxMemHeapAddRef (
void** ppvMemHeap);
141 EXTERNRT
void* rtxMemHeapAlloc (
void** ppvMemHeap,
size_t nbytes);
142 EXTERNRT
void* rtxMemHeapAllocZ (
void** ppvMemHeap,
size_t nbytes);
143 EXTERNRT
void* rtxMemHeapSysAlloc (
void** ppvMemHeap,
size_t nbytes);
144 EXTERNRT
void* rtxMemHeapSysAllocZ (
void** ppvMemHeap,
size_t nbytes);
145 EXTERNRT
int rtxMemHeapCheckPtr (
void** ppvMemHeap,
const void* mem_p);
146 EXTERNRT
void rtxMemHeapFreeAll (
void** ppvMemHeap);
147 EXTERNRT
void rtxMemHeapFreePtr (
void** ppvMemHeap,
void* mem_p);
148 EXTERNRT
void rtxMemHeapSysFreePtr (
void** ppvMemHeap,
void* mem_p);
150 EXTERNRT
void* rtxMemHeapRealloc
151 (
void** ppvMemHeap,
void* mem_p,
size_t nbytes_);
153 EXTERNRT
void* rtxMemHeapSysRealloc
154 (
void** ppvMemHeap,
void* mem_p,
size_t nbytes_);
156 EXTERNRT
void rtxMemHeapRelease (
void** ppvMemHeap);
157 EXTERNRT
void rtxMemHeapReset (
void** ppvMemHeap);
158 EXTERNRT
void rtxMemHeapSetProperty (
void** ppvMemHeap,
159 OSUINT32 propId,
void* pProp);
161 EXTERNRT
void* rtxMemNewArray (
size_t nbytes);
162 EXTERNRT
void* rtxMemNewArrayZ (
size_t nbytes);
163 EXTERNRT
void rtxMemDeleteArray (
void* mem_p);
165 EXTERNRT
void* rtxMemHeapAutoPtrRef (
void** ppvMemHeap,
void* ptr);
166 EXTERNRT
int rtxMemHeapAutoPtrUnref (
void** ppvMemHeap,
void* ptr);
167 EXTERNRT
int rtxMemHeapAutoPtrGetRefCount (
void** ppvMemHeap,
void* mem_p);
169 EXTERNRT
void rtxMemHeapInvalidPtrHook (
void** ppvMemHeap,
const void* mem_p);
171 EXTERNRT
void rtxMemHeapCheck (
void **ppvMemHeap,
const char* file,
int line);
172 EXTERNRT
void rtxMemHeapPrint (
void **ppvMemHeap);
197 OSMallocFunc malloc_func,
198 OSReallocFunc realloc_func,
199 OSFreeFunc free_func);
215 (
void **ppvMemHeap,
void* pmem,
size_t memsize) ;
217 #if !defined(_ARMTCC) && !defined(__SYMBIAN32__) 234 OSReallocFunc realloc_func,
235 OSFreeFunc free_func);
239 EXTERNRT
void rtxMemFreeOpenSeqExt
250 #ifndef __SYMBIAN32__ 286 EXTERNRT OSBOOL
rtxMemIsZero (
const void* pmem,
size_t memsiz);
289 EXTERNRT
void rtxMemSetStaticBuf (
void* memHeapBuf, OSUINT32 blkSize);
301 #define rtxMemAlloc(pctxt,nbytes) \ 302 rtxMemHeapAlloc(&(pctxt)->pMemHeap,nbytes) 314 #define rtxMemSysAlloc(pctxt,nbytes) \ 315 rtxMemHeapSysAlloc(&(pctxt)->pMemHeap,nbytes) 326 #define rtxMemAllocZ(pctxt,nbytes) \ 327 rtxMemHeapAllocZ(&(pctxt)->pMemHeap,nbytes) 342 #define rtxMemSysAllocZ(pctxt,nbytes) \ 343 rtxMemHeapSysAllocZ(&(pctxt)->pMemHeap,nbytes) 360 #define rtxMemRealloc(pctxt,mem_p,nbytes) \ 361 rtxMemHeapRealloc(&(pctxt)->pMemHeap, (void*)mem_p, nbytes) 379 #define rtxMemSysRealloc(pctxt,mem_p,nbytes) \ 380 rtxMemHeapSysRealloc(&(pctxt)->pMemHeap,(void*)mem_p,nbytes) 393 #define rtxMemFreePtr(pctxt,mem_p) \ 394 rtxMemHeapFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 406 #define rtxMemSysFreePtr(pctxt,mem_p) \ 407 rtxMemHeapSysFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 444 #define rtxMemAllocType(pctxt,ctype) \ 445 (ctype*)rtxMemHeapAlloc(&(pctxt)->pMemHeap,sizeof(ctype)) 460 #define rtxMemSysAllocType(pctxt,ctype) \ 461 (ctype*)rtxMemHeapSysAlloc(&(pctxt)->pMemHeap,sizeof(ctype)) 472 #define rtxMemAllocTypeZ(pctxt,ctype) \ 473 (ctype*)rtxMemHeapAllocZ(&(pctxt)->pMemHeap,sizeof(ctype)) 488 #define rtxMemSysAllocTypeZ(pctxt,ctype) \ 489 (ctype*)rtxMemHeapSysAllocZ(&(pctxt)->pMemHeap,sizeof(ctype)) 502 #define rtxMemFreeType(pctxt,mem_p) \ 503 rtxMemHeapFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 516 #define rtxMemSysFreeType(pctxt,mem_p) \ 517 rtxMemHeapSysFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 528 #define rtxMemAllocArray(pctxt,n,type) \ 529 (type*)rtxMemAllocArray2 (pctxt, n, sizeof(type), 0) 531 EXTERNRT
void* rtxMemAllocArray2
532 (
OSCTXT* pctxt, OSSIZE numElements, OSSIZE typeSize, OSUINT32 flags);
547 #define rtxMemSysAllocArray(pctxt,n,type) \ 548 (type*)rtxMemAllocArray2 (pctxt, n, sizeof(type), RT_MH_SYSALLOC) 559 #define rtxMemAllocArrayZ(pctxt,n,type) \ 560 (type*)rtxMemAllocArray2 (pctxt, n, sizeof(type), RT_MH_ZEROARRAY) 573 #define rtxMemFreeArray(pctxt,mem_p) \ 574 rtxMemHeapFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 587 #define rtxMemSysFreeArray(pctxt,mem_p) \ 588 rtxMemHeapSysFreePtr(&(pctxt)->pMemHeap, (void*)mem_p) 604 #define rtxMemReallocArray(pctxt,mem_p,n,type) \ 605 (type*)rtxMemHeapRealloc(&(pctxt)->pMemHeap, (void*)mem_p, sizeof(type)*n) 620 #define rtxMemNewAutoPtr(pctxt,nbytes) \ 621 rtxMemHeapAlloc(&(pctxt)->pMemHeap, nbytes) 631 #define rtxMemAutoPtrRef(pctxt,ptr) \ 632 rtxMemHeapAutoPtrRef(&(pctxt)->pMemHeap, (void*)(ptr)) 644 #define rtxMemAutoPtrUnref(pctxt,ptr) \ 645 rtxMemHeapAutoPtrUnref(&(pctxt)->pMemHeap, (void*)(ptr)) 655 #define rtxMemAutoPtrGetRefCount(pctxt,ptr) \ 656 rtxMemHeapAutoPtrGetRefCount(&(pctxt)->pMemHeap, (void*)(ptr)) 666 #define rtxMemCheckPtr(pctxt,mem_p) \ 667 rtxMemHeapCheckPtr(&(pctxt)->pMemHeap, (void*)mem_p) 674 #define rtxMemCheck(pctxt) \ 675 rtxMemHeapCheck(&(pctxt)->pMemHeap, __FILE__, __LINE__) 682 #define rtxMemPrint(pctxt) \ 683 rtxMemHeapPrint(&(pctxt)->pMemHeap) 692 #define rtxMemSetProperty(pctxt,propId,pProp) \ 693 rtxMemHeapSetProperty (&(pctxt)->pMemHeap, propId, pProp) int rtxMemStaticHeapCreate(void **ppvMemHeap, void *pmem, size_t memsize)
OSUINT32 rtxMemGetDefBlkSize(OSVOIDARG)
OSUINT32 rtxMemHeapGetDefBlkSize(OSCTXT *pctxt)
Definition: rtxDList.h:64
void rtxMemReset(OSCTXT *pctxt)
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)
OSBOOL rtxMemIsZero(const void *pmem, size_t memsiz)
Definition: rtxContext.h:185
void rtxMemFree(OSCTXT *pctxt)