src/string_list.c

changeset 94
9637e3efb8e7
parent 82
44b3332dfe03
--- a/src/string_list.c	Tue Jun 30 11:55:49 2026 +0200
+++ b/src/string_list.c	Tue Jun 30 12:00:16 2026 +0200
@@ -28,11 +28,15 @@
 
 #include <assert.h>
 
+static void do_not_free(void* item) {
+}
+
 string_list_t* new_string_list_t() {
   string_list_t* stringList = malloc(sizeof(string_list_t));
   stringList->count = 0;
   stringList->capacity = 32;
   stringList->items = calloc(sizeof(char*), stringList->capacity);
+  stringList->free_item = do_not_free;
 
   return stringList;
 }
@@ -40,6 +44,9 @@
 void destroy_string_list_t(string_list_t* list) {
   if (list) {
     if (list->items) {
+      for (size_t i = 0 ; i < list->count ; i++) {
+        list->free_item(list->items[i]);
+      }
       free(list->items);
     }
     free(list);

mercurial