util: add stack_Clear

This commit is contained in:
Edgaru089 2021-10-23 21:10:04 +08:00
parent 5293cd52ff
commit f14df89469
2 changed files with 7 additions and 0 deletions

View File

@ -69,3 +69,7 @@ uintptr_t stack_Size(stack *s) {
uintptr_t stack_Space(stack *s) { uintptr_t stack_Space(stack *s) {
return s->top - s->data; return s->top - s->data;
} }
void stack_Clear(stack *s) {
s->top = s->data + s->size;
}

View File

@ -46,6 +46,9 @@ uintptr_t stack_Size(stack *s);
// returns the empty space left in the stack // returns the empty space left in the stack
uintptr_t stack_Space(stack *s); uintptr_t stack_Space(stack *s);
// clears the stack
void stack_Clear(stack *s);
#ifdef __cplusplus #ifdef __cplusplus
} }