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