string_list.c

Thu, 20 Oct 2011 14:13:56 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 20 Oct 2011 14:13:56 +0200
changeset 20
43725438ac50
parent 19
8bac9fd0629d
permissions
-rw-r--r--

Changed author comments + added signatures for upcomming bfile heuristics

     1 /*
     2  * string_list.c
     3  *
     4  *  Created on: 15.09.2011
     5  *      Author: Mike
     6  */
     8 #include "string_list.h"
    10 string_list_t* new_string_list_t() {
    11   string_list_t* stringList = malloc(sizeof(string_list_t));
    12   stringList->count = 0;
    13   stringList->items = NULL;
    15   return stringList;
    16 }
    18 void destroy_string_list_t(string_list_t* list) {
    19   if (list->items != NULL) {
    20     free(list->items);
    21   }
    22   free(list);
    23 }
    25 void add_string(string_list_t* list, char* item) {
    26   char** reallocated_list =
    27     realloc(list->items, sizeof(char*) * (list->count + 1));
    28   if (reallocated_list != NULL) {
    29     list->items = reallocated_list;
    30     list->items[list->count] = item;
    31     list->count++;
    32   }
    33 }

mercurial