delete() for all structures.

This commit is contained in:
Murilo Soares Pereira 2010-04-06 21:59:21 -03:00
parent ecaa2a4c68
commit 90c7ce6280
5 changed files with 36 additions and 2 deletions

View File

@ -40,3 +40,24 @@ void initialize_deck(struct deck *deck) {
return;
}
void delete_deck(struct deck *deck) {
delete_stack(deck->stock);
delete_stack(deck->foundation_0);
delete_stack(deck->foundation_1);
delete_stack(deck->foundation_2);
delete_stack(deck->foundation_3);
delete_stack(deck->maneuvre_0);
delete_stack(deck->maneuvre_1);
delete_stack(deck->maneuvre_2);
delete_stack(deck->maneuvre_3);
delete_stack(deck->maneuvre_4);
delete_stack(deck->maneuvre_5);
delete_stack(deck->maneuvre_6);
free(deck);
return;
}

View File

@ -22,6 +22,7 @@ struct deck {
void allocate_deck(struct deck **);
void initialize_deck(struct deck *);
//void delete_deck(struct deck *);
void delete_deck(struct deck *);
void shuffle_deck(struct deck *);
#endif

View File

@ -42,6 +42,8 @@ void draw_empty_stacks() {
delwin(empty_stack[i]);
}
free(empty_stack);
return;
}
@ -49,6 +51,9 @@ void initialize_game() {
struct deck *deck = NULL;
draw_empty_stacks();
allocate_deck(&deck);
initialize_deck(deck);
delete_deck(deck);
return;
}

View File

@ -11,12 +11,18 @@ void allocate_stack(struct stack **stack) {
}
void initialize_stack(struct stack *stack) {
stack->card = NULL;
stack->next = NULL;
return;
}
void delete_stack(struct stack *stack) {
delete_card(stack->card);
free(stack);
return;
}
bool empty(struct stack *stack) {
return(stack->card == NULL);
}

View File

@ -10,6 +10,7 @@ struct stack {
void allocate_stack(struct stack **);
void initialize_stack(struct stack *);
void delete_stack(struct stack *);
bool empty(struct stack *);
int length(struct stack *);
void push(struct stack **, struct card *);