diff --git a/stack.c b/stack.c index 016ff5b..fd10639 100644 --- a/stack.c +++ b/stack.c @@ -41,5 +41,12 @@ return stack->data; // Clears stack and releases all memory. void clearStack(StackNode *stack) { +StackNode *current = stack; +while (current != NULL) + { + StackNode *next = current->next; + free(current); + current = next; + } } \ No newline at end of file