Fix a bug when deleting the memory. With the first call

to mem_delete() all the hash table is deleted, a second
call to mem_delete() does not have any further effect, so
has to be avoided.
This commit is contained in:
Holger Vogt 2023-11-18 09:58:30 +01:00
parent e57979d15d
commit 10756111bf
1 changed files with 3 additions and 0 deletions

View File

@ -126,6 +126,8 @@ void my_key_free(void * key)
void mem_delete(void) {
#ifdef DB
char buf[128];
if (!memory_table)
return;
printf("CPL GC memory allocated %d times, freed %d times\n", mem_in, mem_out);
printf("CPL GC size of hash table to be freed: %d entries.\n", nghash_get_size(memory_table));
#ifdef DB_FULL
@ -142,6 +144,7 @@ void mem_delete(void) {
#endif
gc_is_on = 0;
nghash_free(memory_table, NULL, my_key_free);
memory_table = NULL;
#ifdef DB
/* printf via sh_printf will need some info from variables that have
been deleted already, therefore we use fputs */