Initialization

This commit is contained in:
Kozar 2024-04-17 16:02:06 +02:00
parent a4f6ef7cd2
commit f458f07805

View File

@ -10,11 +10,23 @@ 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* temp = snake; if (snake == NULL) {
if (snake!= NULL) { return NULL;
snake = snake->next;
free(temp);
} }
if (snake->next == NULL) {
free(snake);
return NULL;
}
struct snake* current = snake;
while (current->next->next != NULL) {
current = current->next;
}
free(current->next);
current->next = NULL;
return snake; return snake;
} }