diff --git a/cv9/snake.c b/cv9/snake.c index d242234..00e921e 100644 --- a/cv9/snake.c +++ b/cv9/snake.c @@ -2,13 +2,14 @@ #include struct snake* add_snake(struct snake* snake,int x,int y){ - if (snake == NULL) { + struct snake* head = calloc(1,sizeof(struct snake)); + if (head == NULL) { return NULL; } - struct snake* head = calloc(1,sizeof(struct snake)); head->x = x; head->y = y; head->next = snake; + return head; } struct snake* remove_snake(struct snake* snake){