Skip to content

Commit 694204f

Browse files
hp_list: Fix bug in list_hp_retire (#10)
In list_hp_retire function of hp_list, the original code would skip the next element if a deletion happens. It was incorrect because of its neglect to adjust the index simultaneously, skipping track of the object origin from &rl->list[iret + 1]. This patch then changed the behavior as: - If reorganize happens, keep the same index for next iteration. - Else, index++.
1 parent 381cb8c commit 694204f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

hp_list/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void list_hp_retire(list_hp_t *hp, uintptr_t ptr)
234234
if (rl->size < HP_THRESHOLD_R)
235235
return;
236236

237-
for (size_t iret = 0; iret < rl->size; iret++) {
237+
for (size_t iret = 0; iret < rl->size;) {
238238
uintptr_t obj = rl->list[iret];
239239
bool can_delete = true;
240240
for (int itid = 0; itid < HP_MAX_THREADS && can_delete; itid++) {
@@ -251,6 +251,8 @@ void list_hp_retire(list_hp_t *hp, uintptr_t ptr)
251251
memmove(&rl->list[iret], &rl->list[iret + 1], bytes);
252252
rl->size--;
253253
hp->deletefunc((void *) obj);
254+
} else {
255+
iret++;
254256
}
255257
}
256258
}

0 commit comments

Comments
 (0)