Remove destroy flag from MemoryManager::delete_var(). #1301

This commit is contained in:
John M. Penn 2022-07-28 15:00:55 -05:00
parent 36416c1973
commit d94d5fc863
4 changed files with 6 additions and 8 deletions

View File

@ -301,7 +301,7 @@ namespace Trick {
@param address - the address of the variable.
@return 0 = SUCCESS, 1 = FAILURE
*/
int delete_var(void* address, bool destroy = true);
int delete_var(void* address);
/**
Forget about the variable with the given name and deallocate the memory associated with it.

View File

@ -37,10 +37,10 @@
return addr ; \
} ; \
static void operator delete (void *p) { \
if ( get_alloc_info_at(p) ) { trick_MM->delete_var(p, false) ; free(p) ; } \
if ( get_alloc_info_at(p) ) { trick_MM->delete_var(p) ; free(p) ; } \
} ; \
static void operator delete[] (void *p) { \
if ( get_alloc_info_at(p) ) { trick_MM->delete_var(p, false) ; free(p) ; } \
if ( get_alloc_info_at(p) ) { trick_MM->delete_var(p) ; free(p) ; } \
} ;
#endif

View File

@ -307,7 +307,7 @@ void Trick::MemoryManager::reset_memory() {
n_addrs = deletion_list.size();
for (ii = 0 ; ii < n_addrs ; ii ++) {
delete_var( deletion_list[ii], false);
delete_var( deletion_list[ii]);
}
// reset counter to 100mil. This (hopefully) ensures all alloc'ed ids are after external variables.

View File

@ -6,7 +6,7 @@
#include "trick/MemoryManager.hh"
// MEMBER FUNCTION
int Trick::MemoryManager::delete_var(void* address, bool destroy ) {
int Trick::MemoryManager::delete_var(void* address ) {
if (address == 0) {
if (debug_level) {
@ -37,9 +37,7 @@ int Trick::MemoryManager::delete_var(void* address, bool destroy ) {
*/
if ( alloc_info->stcl == TRICK_LOCAL ) {
if ( alloc_info->alloc_type == TRICK_ALLOC_MALLOC ) {
if (destroy) {
io_src_destruct_class( alloc_info );
}
io_src_destruct_class( alloc_info );
free( address);
} else if ( alloc_info->alloc_type == TRICK_ALLOC_NEW ) {
io_src_delete_class( alloc_info );