scl/src/include/stack.h

24 lines
466 B
C
Raw Normal View History

2024-10-26 10:56:11 -04:00
#ifndef STACK_H
#define STACK_H
#include <stdlib.h>
#define STACK_MAX 64
typedef struct {
2024-10-31 16:44:17 -04:00
size_t i; // Current index in the stack.
void* val[STACK_MAX]; // The stack itself.
2024-10-26 10:56:11 -04:00
} Stack;
Stack* stack_init();
2024-10-31 16:44:17 -04:00
// Destroy a stack.
// Note that `stack->i` must be `0`.
2024-10-26 10:56:11 -04:00
void stack_destroy(Stack* stack);
2024-10-31 16:44:17 -04:00
// Push a value to the stack.
2024-10-26 10:56:11 -04:00
void stack_push(Stack* stack, void* val);
2024-10-31 16:44:17 -04:00
// Pop a value from the stack.
2024-10-26 10:56:11 -04:00
void* stack_pop(Stack* stack);
#endif