cmLinkHeap.h/c : Added cmLHeapIsPtrInHeap().
This commit is contained in:
parent
80498f4f79
commit
5464cbf4e4
@ -100,10 +100,10 @@ void* _cmLHeapAllocCb(void* funcArgPtr, unsigned byteCnt)
|
||||
return _cmLHeapAlloc(p,byteCnt);
|
||||
}
|
||||
|
||||
bool _cmLHeapFree( cmLHeap_t* lhp, void* dataPtr )
|
||||
{
|
||||
cmLhBlock_t* _cmLHeapPtrToBlock( cmLHeap_t* lhp, const void* dataPtr )
|
||||
{
|
||||
if( dataPtr == NULL )
|
||||
return true;
|
||||
return NULL;
|
||||
|
||||
cmLhBlock_t* lbp = lhp->first;
|
||||
|
||||
@ -111,6 +111,24 @@ bool _cmLHeapFree( cmLHeap_t* lhp, void* dataPtr )
|
||||
while( (lbp != NULL ) && (((char*)dataPtr < lbp->basePtr) || ((char*)dataPtr >= lbp->endPtr)))
|
||||
lbp = lbp->nextBlkPtr;
|
||||
|
||||
return lbp;
|
||||
}
|
||||
|
||||
bool _cmLHeapFree( cmLHeap_t* lhp, void* dataPtr )
|
||||
{
|
||||
if( dataPtr == NULL )
|
||||
return true;
|
||||
|
||||
/*
|
||||
cmLhBlock_t* lbp = lhp->first;
|
||||
|
||||
// locate the block containing the area to free
|
||||
while( (lbp != NULL ) && (((char*)dataPtr < lbp->basePtr) || ((char*)dataPtr >= lbp->endPtr)))
|
||||
lbp = lbp->nextBlkPtr;
|
||||
*/
|
||||
|
||||
cmLhBlock_t* lbp = _cmLHeapPtrToBlock(lhp,dataPtr);
|
||||
|
||||
// the pointer must be in one of the blocks
|
||||
if( lbp == NULL )
|
||||
return false;
|
||||
@ -296,6 +314,12 @@ void cmLHeapClear( cmLHeapH_t h, bool releaseFl )
|
||||
}
|
||||
}
|
||||
|
||||
bool cmLHeapIsPtrInHeap( cmLHeapH_t h, const void* ptr )
|
||||
{
|
||||
cmLHeap_t* lhp = _cmLHeapHandleToPtr(h);
|
||||
return _cmLHeapPtrToBlock(lhp,ptr) != NULL;
|
||||
}
|
||||
|
||||
cmMmRC_t cmLHeapReportErrors( cmLHeapH_t h, unsigned mmFlags )
|
||||
{
|
||||
cmLHeap_t* lhp = _cmLHeapHandleToPtr(h);
|
||||
|
@ -37,6 +37,9 @@ extern "C" {
|
||||
// release the associated memory, otherwise releases all memory blocks.
|
||||
void cmLHeapClear( cmLHeapH_t h, bool releaseFl );
|
||||
|
||||
// Return true if 'ptr' points into a linked heap block.
|
||||
bool cmLHeapIsPtrInHeap( cmLHeapH_t h, const void* ptr );
|
||||
|
||||
// mmFlags take the same values as the flags parameter to cmMmReport().
|
||||
cmMmRC_t cmLHeapReportErrors( cmLHeapH_t h, unsigned mmFlags );
|
||||
void cmLHeapReport( cmLHeapH_t h );
|
||||
|
Loading…
Reference in New Issue
Block a user