diff options
-rw-r--r-- | src/reflist.c | 12 | ||||
-rw-r--r-- | tests/list_check.c | 3 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/reflist.c b/src/reflist.c index 4b08b3af..20021ed3 100644 --- a/src/reflist.c +++ b/src/reflist.c @@ -432,7 +432,7 @@ Reflection *first_refl(RefList *list, RefListIterator **piter) return NULL; } - refl = iter->stack[iter->stack_ptr--]; + refl = iter->stack[--iter->stack_ptr]; return refl; @@ -442,11 +442,15 @@ Reflection *first_refl(RefList *list, RefListIterator **piter) Reflection *next_refl(Reflection *refl, RefListIterator *iter) { + int returned = 1; + do { - refl = refl->child[1];; + if ( returned ) refl = refl->child[1]; + returned = 0; if ( refl != NULL ) { + iter->stack[iter->stack_ptr++] = refl; if ( iter->stack_ptr == iter->stack_size ) { iter->stack_size += 32; @@ -455,15 +459,15 @@ Reflection *next_refl(Reflection *refl, RefListIterator *iter) } refl = refl->child[0]; continue; + } if ( iter->stack_ptr == 0 ) { free(iter->stack); free(iter); return NULL; } - refl = iter->stack[iter->stack_ptr--]; - return refl; + return iter->stack[--iter->stack_ptr]; } while ( 1 ); } diff --git a/tests/list_check.c b/tests/list_check.c index ffae8d12..22ef01e1 100644 --- a/tests/list_check.c +++ b/tests/list_check.c @@ -45,8 +45,6 @@ static int test_lists(int num_items) check = malloc(num_items * sizeof(struct refltemp)); list = reflist_new(); - printf("Testing with %i\n", num_items); - h = RANDOM_INDEX; k = RANDOM_INDEX; l = RANDOM_INDEX; @@ -98,7 +96,6 @@ static int test_lists(int num_items) signed int h, k, l; get_indices(refl, &h, &k, &l); - printf("%3i %3i %3i\n", h, k, l); for ( i=0; i<num_items; i++ ) { if ( (check[i].h == h) |