Skip to content

Commit

Permalink
Add deletions to tracking list if malloc or new (#1778)
Browse files Browse the repository at this point in the history
* Add deletions to tracking list if malloc or new

* Add all TRICK_LOCAL deletions to deletion_list
  • Loading branch information
excaliburtb authored Sep 26, 2024
1 parent 077064f commit 1a842a6
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 1a842a6

Please sign in to comment.