Fix all memory leaks reported by valgrind
This commit is contained in:
@@ -162,6 +162,7 @@ static void shuffle_deck(struct deck *deck) {
|
||||
for (int i = 0; i < NUMBER_OF_CARDS; i++) {
|
||||
stack_push(&(deck->stock), card[i]);
|
||||
}
|
||||
free(card);
|
||||
}
|
||||
|
||||
static void deal_cards(struct deck *deck) {
|
||||
|
||||
@@ -69,6 +69,7 @@ int stack_length(struct stack *stack) {
|
||||
void stack_push(struct stack **stack, struct card *card) {
|
||||
if (card) {
|
||||
if (stack_empty(*stack)) {
|
||||
card_free((*stack)->card);
|
||||
(*stack)->card = card;
|
||||
} else {
|
||||
/* Allocating by hand because stack_malloc() would
|
||||
|
||||
Reference in New Issue
Block a user