From f7043cc03a0a851f20d6a6d83513db340e29168e Mon Sep 17 00:00:00 2001 From: lisk77 Date: Sun, 17 Aug 2025 17:08:14 +0200 Subject: [PATCH] docs(action_list): small comments --- include/action_list.h | 2 ++ src/action_list.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/include/action_list.h b/include/action_list.h index 4f409f8..390f052 100644 --- a/include/action_list.h +++ b/include/action_list.h @@ -11,12 +11,14 @@ typedef enum { DELETE } ActionType; +// Represents a deletion or insertion into the files text typedef struct { ActionType type; uint64_t line_original; uint64_t line_changed; } Action; +// Dynamic array of Actions typedef struct { Action* actions; uint64_t capacity; diff --git a/src/action_list.c b/src/action_list.c index ab4b80b..ef4be48 100644 --- a/src/action_list.c +++ b/src/action_list.c @@ -1,5 +1,6 @@ #include "action_list.h" +// Create a new ActionList ActionList* new_list() { ActionList* list = calloc(1, sizeof(ActionList)); list->capacity = 10; @@ -8,6 +9,7 @@ ActionList* new_list() { return list; } +// Add an Action to the end of the ActionList void add_action(ActionList* list, Action action) { if (list->len >= list->capacity) { list->capacity *= 2; @@ -21,6 +23,7 @@ void add_action(ActionList* list, Action action) { list->actions[list->len++] = action; } +// Concatenate two ActionLists. Modifies list1 in place void append_list(ActionList* list1, ActionList* list2) { uint64_t available_space = list1->capacity - list1->len; if (available_space < list2->len) {