Name-spaced functions for deck.

This commit is contained in:
Murilo Pereira 2011-06-06 02:04:03 -03:00
parent 95a1c77a25
commit bc6b04eb36
3 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@
#include "deck.h"
#include "common.h"
void allocate_deck(struct deck **deck) {
void deck_malloc(struct deck **deck) {
if (!(*deck = malloc(sizeof(**deck)))) {
fprintf(stderr, tty_solitaire_error_message(errno, __FILE__, __LINE__));
exit(errno);
@ -21,7 +21,7 @@ void allocate_deck(struct deck **deck) {
}
}
void initialize_deck(struct deck *deck) {
void deck_init(struct deck *deck) {
stack_init(deck->stock);
stack_init(deck->waste_pile);
for (int i = 0; i < FOUNDATION_STACKS_NUMBER; i++) {
@ -32,7 +32,7 @@ void initialize_deck(struct deck *deck) {
}
}
void free_deck(struct deck *deck) {
void deck_free(struct deck *deck) {
stack_free(deck->stock);
stack_free(deck->waste_pile);
for (int i = 0; i < FOUNDATION_STACKS_NUMBER; i++) {

View File

@ -13,8 +13,8 @@ struct deck {
struct stack *maneuvre[MANEUVRE_STACKS_NUMBER];
};
void allocate_deck(struct deck **);
void initialize_deck(struct deck *);
void free_deck(struct deck *);
void deck_malloc(struct deck **);
void deck_init(struct deck *);
void deck_free(struct deck *);
#endif

View File

@ -180,8 +180,8 @@ static void deal_cards(struct deck *deck) {
void game_init() {
allocate_cursor(&cursor);
initialize_cursor(cursor);
allocate_deck(&deck);
initialize_deck(deck);
deck_malloc(&deck);
deck_init(deck);
/* Setting initial stacks' coordinates. */
set_frame(deck->stock->card->frame, STOCK_BEGIN_Y, STOCK_BEGIN_X);
@ -203,7 +203,7 @@ void game_init() {
void game_end() {
free_cursor(cursor);
free_deck(deck);
deck_free(deck);
}
bool game_won() {