From 84383a3275e1c1fb916aa693be9a9a2a024b5742 Mon Sep 17 00:00:00 2001 From: Murilo Soares Pereira Date: Sun, 4 Apr 2010 00:51:14 -0300 Subject: [PATCH] Fixed length(). --- lib/stack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/stack.c b/lib/stack.c index 53a9aaa..deba919 100644 --- a/lib/stack.c +++ b/lib/stack.c @@ -19,12 +19,14 @@ bool empty(struct stack *stack) { } int length(struct stack *stack) { + struct stack *iterator = stack; int length = 0; if (!empty(stack)) { length = 1; - while (stack->next != NULL) { + while (iterator->next != NULL) { length++; + iterator = iterator->next; } }