From c21d373a5a4010fbe24365597b1e4b4289519b67 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 21 Apr 2021 15:31:40 +0800 Subject: [PATCH] Should increase mt_in_use_c only when the new mem_entry_t is allocated Signed-off-by: Xiang Xiao Change-Id: Ide9fdbc24773db046f29c26582777f5115d60186 --- dmalloc_tab.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/dmalloc_tab.c b/dmalloc_tab.c index a40b3864..a20f0912 100644 --- a/dmalloc_tab.c +++ b/dmalloc_tab.c @@ -591,15 +591,18 @@ void _dmalloc_table_insert(mem_table_t *mem_table, mem_entry_t *entry_p; entry_p = table_find(mem_table, file, line); - if (entry_p->me_file == NULL - && mem_table->mt_in_use_c > mem_table->mt_entry_n / 2) { - /* do we have too many entries in the table? then put in other bucket. */ - entry_p = &mem_table->mt_other_pointers; - } else if (entry_p != &mem_table->mt_other_pointers) { - /* we found an open slot so update the file/line */ - entry_p->me_file = file; - entry_p->me_line = line; - mem_table->mt_in_use_c++; + if (entry_p->me_file == NULL) { + if (mem_table->mt_in_use_c > mem_table->mt_entry_n / 2) { + /* do we have too many entries in the table? then put in other bucket. */ + entry_p = &mem_table->mt_other_pointers; + } + else { + /* we found an open slot so update the file/line */ + entry_p->me_file = file; + entry_p->me_line = line; + entry_p->me_entry_pos_p = entry_p; + mem_table->mt_in_use_c++; + } } /* update the info for the entry */ @@ -607,7 +610,6 @@ void _dmalloc_table_insert(mem_table_t *mem_table, entry_p->me_total_c++; entry_p->me_in_use_size += size; entry_p->me_in_use_c++; - entry_p->me_entry_pos_p = entry_p; } /*