Изменил(а) на 'du7/snake.c'
This commit is contained in:
parent
bdb6a9b609
commit
3c3f421d33
21
du7/snake.c
21
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* remove_snake(struct snake* snake) {
|
||||||
struct snake* this = head;
|
if (snake == NULL || snake->next == NULL) {
|
||||||
this = this->next;
|
free(snake);
|
||||||
while (this->next != NULL){
|
return NULL;
|
||||||
this = this->next;
|
|
||||||
}
|
}
|
||||||
this = head;
|
struct snake* current = snake;
|
||||||
while (this != NULL){
|
struct snake* prev = NULL;
|
||||||
// Niečo môžme s prvkom this spraviť
|
while (current->next != NULL) {
|
||||||
this= this->next;
|
prev = current;
|
||||||
|
current = current->next;
|
||||||
|
}
|
||||||
|
free(current);
|
||||||
|
current = NULL;
|
||||||
|
prev->next = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user