Skip to content

Commit

Permalink
Major bugfix. Corrected terrible malloc error
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasMW committed Oct 5, 2016
1 parent 8fe3dd6 commit e210694
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

Expand All @@ -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)
Expand Down

0 comments on commit e210694

Please sign in to comment.