Add deletions to tracking list if malloc or new (#1778)

* Add deletions to tracking list if malloc or new

* Add all TRICK_LOCAL deletions to deletion_list
This commit is contained in:
Thomas Brain 2024-09-26 11:23:50 -05:00 committed by GitHub
parent 077064f225
commit 1a842a6b89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,19 +37,18 @@ int Trick::MemoryManager::delete_var(void* address ) {
MemoryManager allocated it.
*/
if ( alloc_info->stcl == TRICK_LOCAL ) {
if ( alloc_info->alloc_type == TRICK_ALLOC_MALLOC ) {
// This will call a destructor ONLY if alloc_info->type is TRICK_STRUCTURED.
// Otherwise it does nothing.
io_src_destruct_class( alloc_info );
// The destructor that we just called MAY have deleted addresses
// that are already planned for deletion, say during reset_memory.
// So, keep a record of what we've recently deleted so we don't
// to warn that we can't find it, when reset_memory also tries to
// delete that same address.
// delete that same address. Same for TRICK_ALLOC_NEW block
deleted_addr_list.push_back(address);
if ( alloc_info->alloc_type == TRICK_ALLOC_MALLOC ) {
// This will call a destructor ONLY if alloc_info->type is TRICK_STRUCTURED.
// Otherwise it does nothing.
io_src_destruct_class( alloc_info );
free( address);
} else if ( alloc_info->alloc_type == TRICK_ALLOC_NEW ) {
io_src_delete_class( alloc_info );