Fix all memory leaks reported by valgrind

This commit is contained in:
flamin
2019-01-21 16:02:04 -05:00
parent 69bf25f87e
commit 1aa7e560f1
7 changed files with 59 additions and 6 deletions

View File

@@ -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) {

View File

@@ -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