HuntnGather
/trunk/HuntnGather/Gather/StringStack.c |
@@ -30,8 +30,8 @@ |
* Creates a new stringStack with a given size. |
*/ |
stringStack* stringStackCreate(unsigned int size) { |
stringStack *s = (stringStack*)malloc(sizeof(stringStack)); |
if ((s->store = (char**)malloc(size * sizeof(char *))) == NULL) |
stringStack *s = malloc(sizeof(stringStack)); |
if ((s->store = malloc(size * sizeof(char *))) == NULL) |
return NULL; |
s->size = size; |
s->top = 0; |
@@ -52,8 +52,8 @@ |
*/ |
void stringStackPush(stringStack *s, char *e) { |
if (s->top > s->size - 1) |
s->store = (char**)realloc(s->store, ++s->size * sizeof(char *)); |
s->store[s->top] = (char*)malloc((strlen(e) + 1) * sizeof(char)); |
s->store = realloc(s->store, ++s->size * sizeof(char *)); |
s->store[s->top] = malloc((strlen(e) + 1) * sizeof(char)); |
strncpy(s->store[s->top], e, strlen(e) + 1); |
++s->top; |
} |