Изменил(а) на 'du7/snake.c'
This commit is contained in:
parent
de56e6f91c
commit
bdb6a9b609
20
du7/snake.c
20
du7/snake.c
@ -10,21 +10,19 @@ struct snake* add_snake(struct snake* snake, int x, int y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct snake* remove_snake(struct snake* snake) {
|
struct snake* remove_snake(struct snake* snake) {
|
||||||
struct snake* prev = NULL;
|
struct snake* this = head;
|
||||||
struct snake* curr = snake;
|
this = this->next;
|
||||||
while (curr->next != NULL) {
|
while (this->next != NULL){
|
||||||
prev = curr;
|
this = this->next;
|
||||||
curr = curr->next;
|
|
||||||
}
|
}
|
||||||
free(curr);
|
this = head;
|
||||||
if (prev != NULL) {
|
while (this != NULL){
|
||||||
prev->next = NULL;
|
// Niečo môžme s prvkom this spraviť
|
||||||
return snake;
|
this= this->next;
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void free_snake(struct snake* sn) {
|
void free_snake(struct snake* sn) {
|
||||||
while (sn != NULL) {
|
while (sn != NULL) {
|
||||||
struct snake* next = sn->next;
|
struct snake* next = sn->next;
|
||||||
|
Loading…
Reference in New Issue
Block a user