From 315e37b643a3cb08f3e97f37938eeec9b1fe1348 Mon Sep 17 00:00:00 2001 From: lisk77 Date: Thu, 4 Sep 2025 23:12:36 +0200 Subject: [PATCH] feat(actions): added content field to Action to copy the insert text --- include/action_list.h | 2 ++ src/action_list.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/action_list.h b/include/action_list.h index eab87e8..6bf48ae 100644 --- a/include/action_list.h +++ b/include/action_list.h @@ -16,6 +16,7 @@ typedef struct { ActionType type; size_t line_original; size_t line_changed; + char* content; } Action; // Dynamic array of Actions @@ -28,5 +29,6 @@ typedef struct { ActionList* new_list(); void add_action(ActionList*, Action); void append_list(ActionList*, ActionList*); +void free_action_list(ActionList*); #endif // ACTION_LIST_H diff --git a/src/action_list.c b/src/action_list.c index be0638e..d92e9ce 100644 --- a/src/action_list.c +++ b/src/action_list.c @@ -38,3 +38,16 @@ void append_list(ActionList* list1, ActionList* list2) { memcpy(list1->actions + list1->len, list2->actions, list2->len * sizeof *list2->actions); list1->len += list2->len; } + +void free_action_list(ActionList* list) { + if (!list) return; + + for (size_t i = 0; i < list->len; i++) { + if (list->actions[i].content) { + free(list->actions[i].content); // Free content for INSERT actions + } + } + + free(list->actions); // Free the array of actions + free(list); // Free the ActionList itself +} \ No newline at end of file