Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate item detection issue #145

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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