Add initial stack implementation

This commit is contained in:
Rickey Fehr
2026-05-23 12:45:57 -07:00
parent 625185aa94
commit fbe1b1e9ec
7 changed files with 116 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
#include "stack.h"
#include "stddef.h"
void stack_reset(Stack* stack)
{
stack->top = -1;
}
bool stack_empty(Stack* stack)
{
return stack->top < 0;
}
int stack_len(Stack* stack)
{
}
void stack_push(Stack* stack, void* data)
{
if (stack->top < stack->max)
stack->data_array[++stack->top] = data;
}
void* stack_pop(Stack* stack)
{
return (stack->top < 0) ? NULL : stack->data_array[stack->top--];
}