Skip to content

Commit 287ac3e

Browse files
Handle the empty skip_free_list correctly
by switching to free_wait_list_head directly Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I89faa38296157a953cd564bba90c538eae5d43ed
1 parent 2830065 commit 287ac3e

File tree

1 file changed

+30
-45
lines changed

1 file changed

+30
-45
lines changed

chunk.c

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,23 +2016,18 @@ int _dmalloc_chunk_heap_check(void)
20162016
* switch to the free list in the middle after we've checked the
20172017
* used pointer slots
20182018
*/
2019-
if (slot_p == NULL) {
2020-
checking_list_c++;
2021-
if (checking_list_c == 1) {
2022-
slot_p = skip_free_list->sa_next_p[0];
2023-
}
2019+
if (slot_p == NULL && checking_list_c == 0) {
2020+
slot_p = skip_free_list->sa_next_p[0];
2021+
checking_list_c = 1;
2022+
}
20242023
#if FREED_POINTER_DELAY
2025-
else if (checking_list_c == 2) {
2026-
slot_p = free_wait_list_head;
2027-
}
2024+
if (slot_p == NULL && checking_list_c == 1) {
2025+
slot_p = free_wait_list_head;
2026+
checking_list_c = 2;
2027+
}
20282028
#endif
2029-
else {
2030-
/* we are done */
2031-
break;
2032-
}
2033-
if (slot_p == NULL) {
2034-
break;
2035-
}
2029+
if (slot_p == NULL) {
2030+
break;
20362031
}
20372032

20382033
/* better be in the heap */
@@ -2852,23 +2847,18 @@ void _dmalloc_chunk_log_changed(const unsigned long mark,
28522847
* switch to the free list in the middle after we've checked the
28532848
* used pointer slots
28542849
*/
2855-
if (slot_p == NULL) {
2856-
checking_list_c++;
2857-
if (checking_list_c == 1) {
2858-
slot_p = skip_free_list->sa_next_p[0];
2859-
}
2850+
if (slot_p == NULL && checking_list_c == 0) {
2851+
slot_p = skip_free_list->sa_next_p[0];
2852+
checking_list_c = 1;
2853+
}
28602854
#if FREED_POINTER_DELAY
2861-
else if (checking_list_c == 2) {
2862-
slot_p = free_wait_list_head;
2863-
}
2855+
if (slot_p == NULL && checking_list_c == 1) {
2856+
slot_p = free_wait_list_head;
2857+
checking_list_c = 2;
2858+
}
28642859
#endif
2865-
else {
2866-
/* we are done */
2867-
break;
2868-
}
2869-
if (slot_p == NULL) {
2870-
break;
2871-
}
2860+
if (slot_p == NULL) {
2861+
break;
28722862
}
28732863

28742864
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,
29822972
* switch to the free list in the middle after we've checked the
29832973
* used pointer slots
29842974
*/
2985-
if (slot_p == NULL) {
2986-
checking_list_c++;
2987-
if (checking_list_c == 1) {
2988-
slot_p = skip_free_list->sa_next_p[0];
2989-
}
2975+
if (slot_p == NULL && checking_list_c == 0) {
2976+
slot_p = skip_free_list->sa_next_p[0];
2977+
checking_list_c = 1;
2978+
}
29902979
#if FREED_POINTER_DELAY
2991-
else if (checking_list_c == 2) {
2992-
slot_p = free_wait_list_head;
2993-
}
2980+
if (slot_p == NULL && checking_list_c == 1) {
2981+
slot_p = free_wait_list_head;
2982+
checking_list_c = 2;
2983+
}
29942984
#endif
2995-
else {
2996-
/* we are done */
2997-
break;
2998-
}
2999-
if (slot_p == NULL) {
3000-
break;
3001-
}
2985+
if (slot_p == NULL) {
2986+
break;
30022987
}
30032988

30042989
freed_b = BIT_IS_SET(slot_p->sa_flags, ALLOC_FLAG_FREE);

0 commit comments

Comments
 (0)