From f14df894698c46ee1c93e121923f3539ffb303d7 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Sat, 23 Oct 2021 21:10:04 +0800 Subject: [PATCH] util: add stack_Clear --- util/stack.c | 4 ++++ util/stack.h | 3 +++ 2 files changed, 7 insertions(+) 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 }