feat(actions): added content field to Action to copy the insert text

This commit is contained in:
lisk77 2025-09-04 23:12:36 +02:00
parent 1dd9e2cbca
commit 315e37b643
2 changed files with 15 additions and 0 deletions

View file

@ -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

View file

@ -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
}