feat: add stack

This commit is contained in:
2025-09-10 16:45:50 +02:00
parent 9c037c5e25
commit 610bf5dab9
8 changed files with 161 additions and 12 deletions

25
stack/mystack.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef MYCLIB_STACK_H
#define MYCLIB_STACK_H
#include <stddef.h>
#include <threads.h>
#include "../vector/myvector.h"
typedef struct stack {
vec_s *data;
size_t elem_size;
mtx_t lock;
} stack_s;
stack_s *stack_new(size_t initial_capacity, size_t element_size);
void *stack_pop(stack_s *stack);
int stack_push(stack_s *stack, void *elem);
void *stack_top(stack_s *stack);
void stack_free(stack_s *stack);
#endif