Avoid dereferencing NULL pointers.

This commit is contained in:
Murilo Pereira 2011-02-12 01:26:03 -02:00
parent 97c69bdcba
commit 60641ca499
4 changed files with 23 additions and 17 deletions

View File

@ -26,7 +26,9 @@ void initialize_card(struct card *card) {
}
void delete_card(struct card *card) {
if (card) {
delete_frame(card->frame);
}
free(card);
return;

View File

@ -51,7 +51,7 @@ void initialize_deck(struct deck *deck) {
}
void delete_deck(struct deck *deck) {
delete_stack(deck->stock);
if (deck) {
delete_stack(deck->waste_pile);
delete_stack(deck->foundation_0);
@ -66,7 +66,7 @@ void delete_deck(struct deck *deck) {
delete_stack(deck->maneuvre_4);
delete_stack(deck->maneuvre_5);
delete_stack(deck->maneuvre_6);
}
free(deck);
return;

View File

@ -23,7 +23,9 @@ void initialize_frame(struct frame *frame) {
}
void delete_frame(struct frame *frame) {
if (frame) {
delwin(frame->shape);
}
free(frame);
return;

View File

@ -29,7 +29,9 @@ void initialize_stack(struct stack *stack) {
}
void delete_stack(struct stack *stack) {
if (stack) {
delete_card(stack->card);
}
free(stack);
return;