Skip to content

Commit

Permalink
Merge pull request #145 from ericlinsechs/dedup_bug
Browse files Browse the repository at this point in the history
Fix duplicate item detection issue
  • Loading branch information
eecheng87 authored Nov 11, 2023
2 parents 8434ba3 + 40f20ff commit 8692fc1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions qtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,14 @@ static bool do_dedup(int argc, char *argv[])
}

struct list_head *l_tmp = current->q->next;
bool is_this_dup = false;
// Compare between new list and old one
list_for_each_entry (item, &l_copy, list) {
// Skip comparison with new list if the string is duplicate
bool is_next_dup =
item->list.next != &l_copy &&
strcmp(list_entry(item->list.next, element_t, list)->value,
item->value) == 0;
if (is_this_dup || is_next_dup) {
if (is_next_dup) {
// Update list size
current->size--;
} else if (l_tmp != current->q &&
Expand All @@ -492,7 +491,6 @@ static bool do_dedup(int argc, char *argv[])
l_tmp = l_tmp->next;
else
ok = false;
is_this_dup = is_next_dup;
}
// All elements in new list should be traversed
ok = ok && l_tmp == current->q;
Expand Down

0 comments on commit 8692fc1

Please sign in to comment.