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