// validate a block of memory. returns false if memory had been corrupted. MF_API bool MFHeap_ValidateMemory(const void *pMemory) { MFCALLSTACK; if(!pMemory) return true; MFAllocHeader *pHeader = &((MFAllocHeader*)pMemory)[-1]; if(MFMemCompare(pHeader->llawgnum, gLlawgnum, MFHeap_MungwallBytes) != 0) return false; return MFMemCompare((char*&)pMemory + pHeader->size, gMungwall, MFHeap_MungwallBytes) == 0; }
// validate a block of memory. returns false if memory had been corrupted. MF_API bool MFHeap_ValidateMemory(const void *pMemory) { MFCALLSTACK; if(!pMemory) return true; MFAllocHeader *pHeader = GetAllocHeader(pMemory); if(!pHeader) { MFDebug_Warn(0, MFStr("Missing allocation header for allocation 0x%p.", pMemory)); return false; } #if defined(USE_PRE_MUNGWALL) if(MFMemCompare((const char*)pMemory - MFHeap_MungwallBytes, gLlawgnum, MFHeap_MungwallBytes) == 0) #endif if(MFMemCompare((const char*)pMemory + pHeader->size, gMungwall, MFHeap_MungwallBytes) == 0) return true; MFDebug_Log(0, MFStr("%s(" MFFMT_SIZE_T ") : Corrupted mungwall detected in allocation 0x%p.", pHeader->pFile, pHeader->line, pMemory)); return false; }