fixed pointer fail

Sat, 02 Jul 2011 17:43:20 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 02 Jul 2011 17:43:20 +0200
changeset 9
1dd63a32ffc4
parent 8
28319b20968c
child 11
06cbd0ec003d

fixed pointer fail

cline.c file | annotate | diff | comparison | revisions
cline.h file | annotate | diff | comparison | revisions
--- a/cline.c	Mon May 30 08:45:08 2011 +0200
+++ b/cline.c	Sat Jul 02 17:43:20 2011 +0200
@@ -2,21 +2,16 @@
 #include "functions.h"
 
 suffix_list_t* new_suffix_list_t() {
-  suffix_list_t* suffixList = malloc(sizeof(suffix_list_t*));
+  suffix_list_t* suffixList = malloc(sizeof(suffix_list_t));
   suffixList->count = 0;
   suffixList->items = NULL;
-}
 
-void destroy_suffix_list_t(suffix_list_t* list) {
-  while (--list->count >= 0) {
-    free(list->items[list->count]);
-  }
-  free(list);
+  return suffixList;
 }
 
 void add_suffix(suffix_list_t* list, char* item) {
   char** reallocated_list =
-    realloc(list->items, sizeof(char**) * list->count + 1);
+    realloc(list->items, sizeof(char*) * list->count + 1);
   if (reallocated_list != NULL) {
     list->items = reallocated_list;
     list->items[list->count] = item;
@@ -25,7 +20,7 @@
 }
 
 settings_t* new_settings_t() {
-  settings_t *settings = malloc(sizeof(settings_t*));
+  settings_t *settings = malloc(sizeof(settings_t));
   if (settings != NULL) {
   #ifdef _WIN32
     settings->fileSeparator      = '\\';
@@ -42,7 +37,7 @@
 }
 
 void destroy_settings_t(settings_t* settings) {
-  destroy_suffix_list_t(settings->suffixList);
+  free(settings->suffixList);
   free(settings);
 }
 
--- a/cline.h	Mon May 30 08:45:08 2011 +0200
+++ b/cline.h	Sat Jul 02 17:43:20 2011 +0200
@@ -27,7 +27,6 @@
 settings_t* new_settings_t();
 void destroy_settings_t(settings_t*);
 suffix_list_t* new_suffix_list_t();
-void destroy_suffix_list_t(suffix_list_t*);
 void add_suffix(suffix_list_t*, char*);
 
 void printHelpText(const char*);

mercurial