string_list.c

Thu, 26 Jan 2012 15:55:52 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 26 Jan 2012 15:55:52 +0100
changeset 27
95a958e3de88
parent 20
43725438ac50
permissions
-rw-r--r--

added regexp_parser struct and compile function

/*
 * string_list.c
 *
 *  Created on: 15.09.2011
 *      Author: Mike
 */

#include "string_list.h"

string_list_t* new_string_list_t() {
  string_list_t* stringList = malloc(sizeof(string_list_t));
  stringList->count = 0;
  stringList->items = NULL;

  return stringList;
}

void destroy_string_list_t(string_list_t* list) {
  if (list->items != NULL) {
    free(list->items);
  }
  free(list);
}

void add_string(string_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