suffix_list.c

changeset 10
ecf787666f44
child 11
06cbd0ec003d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/suffix_list.c	Thu Sep 15 13:29:06 2011 +0200
@@ -0,0 +1,34 @@
+/*
+ * suffix_list.c
+ *
+ *  Created on: 15.09.2011
+ *      Author: beckermi
+ */
+
+#include "suffix_list.h"
+
+suffix_list_t* new_suffix_list_t() {
+  suffix_list_t* suffixList = malloc(sizeof(suffix_list_t*));
+  suffixList->count = 0;
+  suffixList->items = NULL;
+
+  return suffixList;
+}
+
+void destroy_suffix_list_t(suffix_list_t* list) {
+  while (--list->count >= 0) {
+    free(list->items[list->count]);
+  }
+  free(list);
+}
+
+void add_suffix(suffix_list_t* list, char* item) {
+  char** reallocated_list =
+    realloc(list->items, sizeof(char**) * list->count + 1);
+  if (reallocated_list != NULL) {
+    list->items = reallocated_list;
+    list->items[list->count] = item;
+    list->count++;
+  }
+}
+

mercurial