From 1a842a6b892fde5cbc4a03a295d12c70ac22a1d9 Mon Sep 17 00:00:00 2001 From: Thomas Brain Date: Thu, 26 Sep 2024 11:23:50 -0500 Subject: [PATCH] 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 --- .../MemoryManager/MemoryManager_delete_var.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp b/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp index 4bde1c45..008485bf 100644 --- a/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp +++ b/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp @@ -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 ) { + // 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. 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 ); - // 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. - deleted_addr_list.push_back(address); - free( address); } else if ( alloc_info->alloc_type == TRICK_ALLOC_NEW ) { io_src_delete_class( alloc_info );