|
@@ -100,16 +100,34 @@ void* _cmLHeapAllocCb(void* funcArgPtr, unsigned byteCnt)
|
100
|
100
|
return _cmLHeapAlloc(p,byteCnt);
|
101
|
101
|
}
|
102
|
102
|
|
|
103
|
+cmLhBlock_t* _cmLHeapPtrToBlock( cmLHeap_t* lhp, const void* dataPtr )
|
|
104
|
+{
|
|
105
|
+ if( dataPtr == NULL )
|
|
106
|
+ return NULL;
|
|
107
|
+
|
|
108
|
+ cmLhBlock_t* lbp = lhp->first;
|
|
109
|
+
|
|
110
|
+ // locate the block containing the area to free
|
|
111
|
+ while( (lbp != NULL ) && (((char*)dataPtr < lbp->basePtr) || ((char*)dataPtr >= lbp->endPtr)))
|
|
112
|
+ lbp = lbp->nextBlkPtr;
|
|
113
|
+
|
|
114
|
+ return lbp;
|
|
115
|
+}
|
|
116
|
+
|
103
|
117
|
bool _cmLHeapFree( cmLHeap_t* lhp, void* dataPtr )
|
104
|
118
|
{
|
105
|
119
|
if( dataPtr == NULL )
|
106
|
120
|
return true;
|
107
|
121
|
|
|
122
|
+ /*
|
108
|
123
|
cmLhBlock_t* lbp = lhp->first;
|
109
|
124
|
|
110
|
125
|
// locate the block containing the area to free
|
111
|
126
|
while( (lbp != NULL ) && (((char*)dataPtr < lbp->basePtr) || ((char*)dataPtr >= lbp->endPtr)))
|
112
|
127
|
lbp = lbp->nextBlkPtr;
|
|
128
|
+ */
|
|
129
|
+
|
|
130
|
+ cmLhBlock_t* lbp = _cmLHeapPtrToBlock(lhp,dataPtr);
|
113
|
131
|
|
114
|
132
|
// the pointer must be in one of the blocks
|
115
|
133
|
if( lbp == NULL )
|
|
@@ -296,6 +314,12 @@ void cmLHeapClear( cmLHeapH_t h, bool releaseFl )
|
296
|
314
|
}
|
297
|
315
|
}
|
298
|
316
|
|
|
317
|
+bool cmLHeapIsPtrInHeap( cmLHeapH_t h, const void* ptr )
|
|
318
|
+{
|
|
319
|
+ cmLHeap_t* lhp = _cmLHeapHandleToPtr(h);
|
|
320
|
+ return _cmLHeapPtrToBlock(lhp,ptr) != NULL;
|
|
321
|
+}
|
|
322
|
+
|
299
|
323
|
cmMmRC_t cmLHeapReportErrors( cmLHeapH_t h, unsigned mmFlags )
|
300
|
324
|
{
|
301
|
325
|
cmLHeap_t* lhp = _cmLHeapHandleToPtr(h);
|