From 287ac3eb06a12d510de46cafa3c21902277cc0d3 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 25 Apr 2021 03:21:14 +0800 Subject: [PATCH] Handle the empty skip_free_list correctly by switching to free_wait_list_head directly Signed-off-by: Xiang Xiao Change-Id: I89faa38296157a953cd564bba90c538eae5d43ed --- chunk.c | 75 +++++++++++++++++++++++---------------------------------- 1 file changed, 30 insertions(+), 45 deletions(-) diff --git a/chunk.c b/chunk.c index 9f3d52f8..9d65147b 100644 --- a/chunk.c +++ b/chunk.c @@ -2016,23 +2016,18 @@ int _dmalloc_chunk_heap_check(void) * switch to the free list in the middle after we've checked the * used pointer slots */ - if (slot_p == NULL) { - checking_list_c++; - if (checking_list_c == 1) { - slot_p = skip_free_list->sa_next_p[0]; - } + if (slot_p == NULL && checking_list_c == 0) { + slot_p = skip_free_list->sa_next_p[0]; + checking_list_c = 1; + } #if FREED_POINTER_DELAY - else if (checking_list_c == 2) { - slot_p = free_wait_list_head; - } + if (slot_p == NULL && checking_list_c == 1) { + slot_p = free_wait_list_head; + checking_list_c = 2; + } #endif - else { - /* we are done */ - break; - } - if (slot_p == NULL) { - break; - } + if (slot_p == NULL) { + break; } /* better be in the heap */ @@ -2852,23 +2847,18 @@ void _dmalloc_chunk_log_changed(const unsigned long mark, * switch to the free list in the middle after we've checked the * used pointer slots */ - if (slot_p == NULL) { - checking_list_c++; - if (checking_list_c == 1) { - slot_p = skip_free_list->sa_next_p[0]; - } + if (slot_p == NULL && checking_list_c == 0) { + slot_p = skip_free_list->sa_next_p[0]; + checking_list_c = 1; + } #if FREED_POINTER_DELAY - else if (checking_list_c == 2) { - slot_p = free_wait_list_head; - } + if (slot_p == NULL && checking_list_c == 1) { + slot_p = free_wait_list_head; + checking_list_c = 2; + } #endif - else { - /* we are done */ - break; - } - if (slot_p == NULL) { - break; - } + if (slot_p == NULL) { + break; } freed_b = BIT_IS_SET(slot_p->sa_flags, ALLOC_FLAG_FREE); @@ -2982,23 +2972,18 @@ unsigned long _dmalloc_chunk_count_changed(const unsigned long mark, * switch to the free list in the middle after we've checked the * used pointer slots */ - if (slot_p == NULL) { - checking_list_c++; - if (checking_list_c == 1) { - slot_p = skip_free_list->sa_next_p[0]; - } + if (slot_p == NULL && checking_list_c == 0) { + slot_p = skip_free_list->sa_next_p[0]; + checking_list_c = 1; + } #if FREED_POINTER_DELAY - else if (checking_list_c == 2) { - slot_p = free_wait_list_head; - } + if (slot_p == NULL && checking_list_c == 1) { + slot_p = free_wait_list_head; + checking_list_c = 2; + } #endif - else { - /* we are done */ - break; - } - if (slot_p == NULL) { - break; - } + if (slot_p == NULL) { + break; } freed_b = BIT_IS_SET(slot_p->sa_flags, ALLOC_FLAG_FREE);