diff --git a/util/stack.c b/util/stack.c index dd842d4..500f9f8 100644 --- a/util/stack.c +++ b/util/stack.c @@ -69,3 +69,7 @@ uintptr_t stack_Size(stack *s) { uintptr_t stack_Space(stack *s) { return s->top - s->data; } + +void stack_Clear(stack *s) { + s->top = s->data + s->size; +} diff --git a/util/stack.h b/util/stack.h index caa7274..30be77b 100644 --- a/util/stack.h +++ b/util/stack.h @@ -46,6 +46,9 @@ uintptr_t stack_Size(stack *s); // returns the empty space left in the stack uintptr_t stack_Space(stack *s); +// clears the stack +void stack_Clear(stack *s); + #ifdef __cplusplus }