JBoolean JMMArrayTable::_SetRecordDeleted ( JMMRecord* record, const void* block, const JCharacter* file, const JUInt32 line, const JBoolean isArray ) { JSize index = FindAllocatedBlock(block); if (index != 0) { JMMRecord thisRecord = itsAllocatedTable->GetElement(index); thisRecord.SetDeleteLocation(file, line, isArray); itsAllocatedBytes -= thisRecord.GetSize(); if (!thisRecord.ArrayNew() && isArray) { NotifyObjectDeletedAsArray(thisRecord); } else if (thisRecord.ArrayNew() && !isArray) { NotifyArrayDeletedAsObject(thisRecord); } itsAllocatedTable->RemoveElement(index); if (itsDeletedTable != NULL) { itsDeletedTable->AppendElement(thisRecord); } else { itsDeletedCount++; } *record = thisRecord; return kJTrue; } else { // Because the array is searched backwards, if it finds a block it // will be the most recent deallocation at that address index = FindDeletedBlock(block); if (index == 0) { NotifyUnallocatedDeletion(file, line, isArray); } else { JMMRecord thisRecord = itsDeletedTable->GetElement(index); NotifyMultipleDeletion(thisRecord, file, line, isArray); } return kJFalse; } }
JBoolean JMMHashTable::_SetRecordDeleted ( JMMRecord* record, const void* block, const JCharacter* file, const JUInt32 line, const JBoolean isArray ) { JHashCursor<JMMRecord> allocCursor(itsAllocatedTable, reinterpret_cast<JHashValue>(block) ); if ( allocCursor.NextHash() ) { JMMRecord thisRecord = allocCursor.GetValue(); thisRecord.SetDeleteLocation(file, line, isArray); itsAllocatedBytes -= thisRecord.GetSize(); if (!thisRecord.ArrayNew() && isArray) { NotifyObjectDeletedAsArray(thisRecord); } else if (thisRecord.ArrayNew() && !isArray) { NotifyArrayDeletedAsObject(thisRecord); } allocCursor.Remove(); if (itsDeletedTable != NULL) { JHashCursor<JMMRecord> deallocCursor(itsDeletedTable, reinterpret_cast<JHashValue>(block) ); deallocCursor.ForceNextOpen(); deallocCursor.Set(reinterpret_cast<JHashValue>(block), thisRecord); } else { itsDeletedCount++; } *record = thisRecord; return kJTrue; } else { if (itsDeletedTable == NULL) { NotifyUnallocatedDeletion(file, line, isArray); } else { JHashCursor<JMMRecord> deallocCursor(itsDeletedTable, reinterpret_cast<JHashValue>(block) ); if ( deallocCursor.NextHash() ) { // Seek most recent deallocation at that address JMMRecord previousRecord = deallocCursor.GetValue(); while ( deallocCursor.NextHash() ) { JMMRecord thisRecord = deallocCursor.GetValue(); if ( thisRecord.GetID() > previousRecord.GetID() ) { previousRecord = thisRecord; } } NotifyMultipleDeletion(previousRecord, file, line, isArray); } else { NotifyUnallocatedDeletion(file, line, isArray); } } return kJFalse; } }