Fixed memory leak.
This commit is contained in:
parent
e5e94cc841
commit
7262ac588f
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user