feat: initial commit

This commit is contained in:
lisk77 2025-08-16 00:45:53 +02:00
commit c18a85f1cc
7 changed files with 153 additions and 0 deletions

37
src/action_list.c Normal file
View file

@ -0,0 +1,37 @@
#include "action_list.h"
ActionList* new_list() {
ActionList* list = calloc(1, sizeof(ActionList));
list->capacity = 10;
list->actions = calloc(list->capacity, sizeof(Action));
list->len = 0;
return list;
}
void add_action(ActionList* list, Action action) {
if (list->len >= list->capacity) {
list->capacity *= 2;
list->actions = realloc(list->actions, list->capacity*sizeof(Action));
if (list->actions == NULL) {
perror("Actions list reallocation failed!");
exit(EXIT_FAILURE);
}
}
list->actions[list->len++] = action;
}
void append_list(ActionList* list1, ActionList* list2) {
uint64_t available_space = list1->capacity - list1->len;
if (available_space < list2->len) {
list1->capacity += list2->capacity;
list1->actions = realloc(list1->actions, list1->capacity*sizeof(Action));
if (list1->actions == NULL) {
perror("Actions list reallaction failed!");
exit(EXIT_FAILURE);
}
}
memcpy(list1->actions + list1->len, list2->actions, list2->len * sizeof *list2->actions);
list1->len += list2->len;
}