From e210694c7d191288eb8d09a4ac12c85778e63969 Mon Sep 17 00:00:00 2001 From: LucasMW Date: Tue, 4 Oct 2016 23:33:01 -0300 Subject: [PATCH] Major bugfix. Corrected terrible malloc error --- stack.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stack.c b/stack.c index 2bb9583..99f7b63 100644 --- a/stack.c +++ b/stack.c @@ -3,17 +3,17 @@ // based on http://groups.csail.mit.edu/graphics/classes/6.837/F04/cpp_notes/stack1.html -struct Stack +typedef struct Stack { char* data[STACK_MAX]; int size; -}; +} Stack; void Stack_Init(Stack **S) { - *S = calloc(sizeof(Stack*),1); + *S = calloc(sizeof(Stack),1); //allocating a Stack //(*S)->data = calloc(sizeof(char*),STACK_MAX); - (*S)->size = 0; + (*S)->size = 0; } @@ -25,7 +25,7 @@ char* Stack_Top(Stack *S) return NULL; } - return (char*)S->data[S->size-1]; + return S->data[S->size-1]; } void Stack_Push(Stack *S, char* d)