Skip to content

Commit

Permalink
fix lst2 win32 global var?
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Mar 28, 2023
1 parent 278c8e4 commit 26f73b5
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ static bool sort_handler2(struct le *le1, struct le *le2, void *arg)
#define NUM_ELEMENTS 100
static int test_sort(bool sorted)
{
struct list lst1;
struct list lst2;
struct list lst_1;
struct list lst_2;
struct le *le;
int prev_value = 0;
bool prev_value_set = false;
unsigned i;
unsigned value_counter = 7;
int err = 0;

list_init(&lst1);
list_init(&lst2);
list_init(&lst_1);
list_init(&lst_2);

/* add many elements with a random value */
for (i=0; i<NUM_ELEMENTS; i++) {
Expand All @@ -164,25 +164,25 @@ static int test_sort(bool sorted)
value_counter *= 3;

if (sorted) {
list_insert_sorted(&lst1, sort_handler1, NULL,
list_insert_sorted(&lst_1, sort_handler1, NULL,
&node->le, node);
list_insert_sorted(&lst2, sort_handler2, NULL,
list_insert_sorted(&lst_2, sort_handler2, NULL,
&node->le2, node);
}
else {
list_append(&lst1, &node->le, node);
list_append(&lst2, &node->le2, node);
list_append(&lst_1, &node->le, node);
list_append(&lst_2, &node->le2, node);
}
}

/* sort the list in ascending order */
if (!sorted) {
list_sort(&lst1, sort_handler1, NULL);
list_sort(&lst2, sort_handler2, NULL);
list_sort(&lst_1, sort_handler1, NULL);
list_sort(&lst_2, sort_handler2, NULL);
}

/* verify that the list is sorted */
for (le = lst1.head; le; le = le->next) {
for (le = lst_1.head; le; le = le->next) {
struct node *node = le->data;

if (prev_value_set) {
Expand All @@ -194,7 +194,7 @@ static int test_sort(bool sorted)
}

prev_value_set = false;
for (le = lst2.head; le; le = le->next) {
for (le = lst_2.head; le; le = le->next) {
struct node *node = le->data;

if (prev_value_set) {
Expand All @@ -206,7 +206,7 @@ static int test_sort(bool sorted)
}

out:
list_flush(&lst1);
list_flush(&lst_1);

return err;
}
Expand Down

0 comments on commit 26f73b5

Please sign in to comment.