aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-02-08 19:24:13 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:13 +0100
commitde518c82717f8d07a6721e01200deb2437335a5d (patch)
treee2aa6fefc373ac82c66303a0389e787fc103815d /src
parente980ed54dc29e025587aba47390727c500aec8f1 (diff)
Make iteration work
Diffstat (limited to 'src')
-rw-r--r--src/reflist.c12
1 files changed, 8 insertions, 4 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 );
}