void stack_destroy(Stack *stack)
Destroys the Stack and frees all allocated nodes and their associated data.
Definition stack.c:39
int stack_size(const Stack *stack)
Retrieves the total number of elements currently stored on the stack.
Definition stack.c:119
void stack_init(Stack *stack, size_t element_size)
Initializes an empty Stack.
Definition stack.c:29
int stack_search(Stack *stack, int(*cmp_fn)(void *, void *), void *key)
Searches for an element in the stack using a comparison function.
Definition stack.c:99
bool stack_pop(Stack *stack)
Pops (removes) the top element from the stack.
Definition stack.c:77
void * stack_top(Stack *stack)
Accesses the top element of the stack without removing it.
Definition stack.c:91
bool stack_push(Stack *stack, const void *data)
Pushes a new element onto the top of the stack.
Definition stack.c:61
Node structure representing an element in the stack.
Definition stack.h:10
void * data
Definition stack.h:11
struct StackNode * next
Definition stack.h:12
Structure representing a generic linked-list-based Stack.
Definition stack.h:18
size_t size
Definition stack.h:21
StackNode * top
Definition stack.h:19
size_t element_size
Definition stack.h:20