s/delete/free/g
This commit is contained in:
parent
e59d089b45
commit
417a8ca2b7
@ -25,9 +25,9 @@ void initialize_card(struct card *card) {
|
||||
return;
|
||||
}
|
||||
|
||||
void delete_card(struct card *card) {
|
||||
void free_card(struct card *card) {
|
||||
if (card) {
|
||||
delete_frame(card->frame);
|
||||
free_frame(card->frame);
|
||||
}
|
||||
free(card);
|
||||
|
||||
|
@ -45,7 +45,7 @@ extern const char *program_name;
|
||||
|
||||
void allocate_card(struct card **);
|
||||
void initialize_card(struct card *);
|
||||
void delete_card(struct card *);
|
||||
void free_card(struct card *);
|
||||
void set_card(struct card *, enum value, enum suit, enum face, int, int);
|
||||
void expose_card(struct card *);
|
||||
void cover_card(struct card *);
|
||||
|
26
lib/deck.c
26
lib/deck.c
@ -50,22 +50,22 @@ void initialize_deck(struct deck *deck) {
|
||||
return;
|
||||
}
|
||||
|
||||
void delete_deck(struct deck *deck) {
|
||||
void free_deck(struct deck *deck) {
|
||||
if (deck) {
|
||||
delete_stack(deck->waste_pile);
|
||||
free_stack(deck->waste_pile);
|
||||
|
||||
delete_stack(deck->foundation_0);
|
||||
delete_stack(deck->foundation_1);
|
||||
delete_stack(deck->foundation_2);
|
||||
delete_stack(deck->foundation_3);
|
||||
free_stack(deck->foundation_0);
|
||||
free_stack(deck->foundation_1);
|
||||
free_stack(deck->foundation_2);
|
||||
free_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_stack(deck->maneuvre_0);
|
||||
free_stack(deck->maneuvre_1);
|
||||
free_stack(deck->maneuvre_2);
|
||||
free_stack(deck->maneuvre_3);
|
||||
free_stack(deck->maneuvre_4);
|
||||
free_stack(deck->maneuvre_5);
|
||||
free_stack(deck->maneuvre_6);
|
||||
}
|
||||
free(deck);
|
||||
|
||||
|
@ -41,6 +41,6 @@ extern const char *program_name;
|
||||
|
||||
void allocate_deck(struct deck **);
|
||||
void initialize_deck(struct deck *);
|
||||
void delete_deck(struct deck *);
|
||||
void free_deck(struct deck *);
|
||||
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@ void initialize_frame(struct frame *frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
void delete_frame(struct frame *frame) {
|
||||
void free_frame(struct frame *frame) {
|
||||
if (frame) {
|
||||
delwin(frame->shape);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ extern const char *program_name;
|
||||
|
||||
void allocate_frame(struct frame **);
|
||||
void initialize_frame(struct frame *);
|
||||
void delete_frame(struct frame *);
|
||||
void free_frame(struct frame *);
|
||||
void set_frame(struct frame *, int, int);
|
||||
|
||||
#endif
|
||||
|
@ -224,7 +224,7 @@ void initialize_game() {
|
||||
}
|
||||
|
||||
void end_game() {
|
||||
delete_deck(deck);
|
||||
free_deck(deck);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -28,12 +28,12 @@ void initialize_stack(struct stack *stack) {
|
||||
return;
|
||||
}
|
||||
|
||||
void delete_stack(struct stack *stack) {
|
||||
void free_stack(struct stack *stack) {
|
||||
struct stack *tmp_stack;
|
||||
|
||||
while (stack) {
|
||||
tmp_stack = stack->next;
|
||||
delete_card(stack->card);
|
||||
free_card(stack->card);
|
||||
free(stack);
|
||||
stack = tmp_stack;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ extern const char *program_name;
|
||||
|
||||
void allocate_stack(struct stack **);
|
||||
void initialize_stack(struct stack *);
|
||||
void delete_stack(struct stack *);
|
||||
void free_stack(struct stack *);
|
||||
bool empty(struct stack *);
|
||||
int length(struct stack *);
|
||||
void push(struct stack **, struct card *);
|
||||
|
@ -11,7 +11,7 @@ void test_initialize_card() {
|
||||
assert(card->suit == NO_SUIT);
|
||||
assert(card->face == NO_FACE);
|
||||
|
||||
delete_card(card);
|
||||
free_card(card);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -31,7 +31,7 @@ void test_set_card() {
|
||||
assert(card->frame->start_y == start_y);
|
||||
assert(card->frame->start_x == start_x);
|
||||
|
||||
delete_card(card);
|
||||
free_card(card);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -45,7 +45,7 @@ void test_expose_card() {
|
||||
|
||||
assert(card->face == EXPOSED);
|
||||
|
||||
delete_card(card);
|
||||
free_card(card);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -59,7 +59,7 @@ void test_cover_card() {
|
||||
|
||||
assert(card->face == COVERED);
|
||||
|
||||
delete_card(card);
|
||||
free_card(card);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ void test_initialize_frame() {
|
||||
assert(frame->start_y == 0);
|
||||
assert(frame->start_x == 0);
|
||||
|
||||
delete_frame(frame);
|
||||
free_frame(frame);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -28,7 +28,7 @@ void test_set_frame() {
|
||||
assert(frame->start_y == start_y);
|
||||
assert(frame->start_x == start_x);
|
||||
|
||||
delete_frame(frame);
|
||||
free_frame(frame);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ void test_initialize_stack() {
|
||||
assert(stack->card->value == NO_VALUE);
|
||||
assert(!stack->next);
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -24,7 +24,7 @@ void test_empty_on_empty_stack() {
|
||||
|
||||
assert(empty(stack));
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -43,7 +43,7 @@ void test_empty_on_non_empty_stack() {
|
||||
|
||||
assert(!empty(stack));
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -63,7 +63,7 @@ void test_push_on_empty_stack() {
|
||||
assert(stack->card == card);
|
||||
assert(!stack->next);
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -88,7 +88,7 @@ void test_push_on_non_empty_stack() {
|
||||
assert(stack->next->card == card_0);
|
||||
assert(!stack->next->next);
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -104,7 +104,7 @@ void test_push_null_on_empty_stack() {
|
||||
assert(stack->card == old_stack->card);
|
||||
assert(stack->next == NULL);
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -125,7 +125,7 @@ void test_push_null_on_non_empty_stack() {
|
||||
assert(stack->card == old_stack->card);
|
||||
assert(stack->next == old_stack->next);
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -142,7 +142,7 @@ void test_pop_on_empty_stack() {
|
||||
assert(empty(stack));
|
||||
assert(!popped_entry);
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -164,7 +164,7 @@ void test_pop_on_stack_with_one_element() {
|
||||
assert(popped_entry->card == card);
|
||||
assert(!popped_entry->next);
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -189,7 +189,7 @@ void test_pop_on_stack_with_more_than_one_element() {
|
||||
assert(popped_entry->card == card[2]);
|
||||
assert(!popped_entry->next);
|
||||
|
||||
delete_stack(stack);
|
||||
free_stack(stack);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -214,8 +214,8 @@ void test_move_card_from_empty_stack_to_empty_stack() {
|
||||
assert(destination == new_destination);
|
||||
assert(stacks_equal(destination, destination_duplicate));
|
||||
|
||||
delete_stack(origin);
|
||||
delete_stack(destination);
|
||||
free_stack(origin);
|
||||
free_stack(destination);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -246,8 +246,8 @@ void test_move_card_from_empty_stack_to_non_empty_stack() {
|
||||
assert(destination == new_destination);
|
||||
assert(stacks_equal(destination, destination_duplicate));
|
||||
|
||||
delete_stack(origin);
|
||||
delete_stack(destination);
|
||||
free_stack(origin);
|
||||
free_stack(destination);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -271,8 +271,8 @@ void test_move_card_from_non_empty_stack_to_empty_stack() {
|
||||
assert(length(destination) == 1);
|
||||
assert(cards_equal(destination->card, card));
|
||||
|
||||
delete_stack(origin);
|
||||
delete_stack(destination);
|
||||
free_stack(origin);
|
||||
free_stack(destination);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -301,8 +301,8 @@ void test_move_card_from_non_empty_stack_to_non_empty_stack() {
|
||||
assert(cards_equal(destination->card, card[0]));
|
||||
assert(cards_equal(destination->next->card, card[1]));
|
||||
|
||||
delete_stack(origin);
|
||||
delete_stack(destination);
|
||||
free_stack(origin);
|
||||
free_stack(destination);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ struct stack *duplicate_stack(struct stack *stack) {
|
||||
while (!empty(tmp_stack)) {
|
||||
push(&new_stack, (pop(&tmp_stack))->card);
|
||||
}
|
||||
delete_stack(tmp_stack);
|
||||
free_stack(tmp_stack);
|
||||
|
||||
return(new_stack);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user