Fixed memory leak.

This commit is contained in:
Murilo Pereira 2011-05-31 02:45:11 -03:00
parent e5e94cc841
commit 7262ac588f

View File

@ -73,8 +73,9 @@ void push(struct stack **stack, struct card *card) {
if (empty(*stack)) {
(*stack)->card = card;
} else {
struct stack *new_stack;
allocate_stack(&new_stack);
/* Allocating by hand because stack#allocate_stack would
* have allocated an unwanted card object. */
struct stack *new_stack = malloc(sizeof(*new_stack));
new_stack->card = card;
new_stack->next = (*stack);
*stack = new_stack;