From 6c5970da62f52ce765940aa6e1ae5fe6b7764b93 Mon Sep 17 00:00:00 2001 From: Murilo Pereira Date: Mon, 14 Feb 2011 00:04:26 -0200 Subject: [PATCH] Delete the whole linked list (omg noob?). --- lib/stack.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/stack.c b/lib/stack.c index 373fd6a..88e3693 100644 --- a/lib/stack.c +++ b/lib/stack.c @@ -29,10 +29,16 @@ void initialize_stack(struct stack *stack) { } void delete_stack(struct stack *stack) { + struct stack *tmp_stack; + if (stack) { - delete_card(stack->card); + while (stack) { + tmp_stack = stack->next; + delete_card(stack->card); + free(stack); + stack = tmp_stack; + } } - free(stack); return; }