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)) {
|
if (empty(*stack)) {
|
||||||
(*stack)->card = card;
|
(*stack)->card = card;
|
||||||
} else {
|
} else {
|
||||||
struct stack *new_stack;
|
/* Allocating by hand because stack#allocate_stack would
|
||||||
allocate_stack(&new_stack);
|
* have allocated an unwanted card object. */
|
||||||
|
struct stack *new_stack = malloc(sizeof(*new_stack));
|
||||||
new_stack->card = card;
|
new_stack->card = card;
|
||||||
new_stack->next = (*stack);
|
new_stack->next = (*stack);
|
||||||
*stack = new_stack;
|
*stack = new_stack;
|
||||||
|
Loading…
Reference in New Issue
Block a user