From 01ea5cc5108759911ede5d7aa6241f366e2da3bc Mon Sep 17 00:00:00 2001 From: ak643du Date: Thu, 11 Apr 2024 14:18:00 +0200 Subject: [PATCH] Initialization --- cv9/snake.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cv9/snake.c b/cv9/snake.c index a897483..30b59b9 100644 --- a/cv9/snake.c +++ b/cv9/snake.c @@ -10,10 +10,11 @@ struct snake* add_snake(struct snake* snake,int x,int y){ } struct snake* remove_snake(struct snake* snake) { - struct snake* temp = snake; - if (snake!= NULL) { - snake = snake->next; - free(temp); + struct snake* head; + struct snake* this = head; + while (this->next != NULL){ + this = this->next; + free(this); } return snake; }