#include #include "snake.h" #include struct snake* add_snake (struct snake* snake, int x, int y) { struct snake* head = NULL; head = malloc(sizeof(struct snake)); if (!head) { return snake; } head->x = x; head->y = y; head->next = NULL; if (snake !=NULL) { head->next = snake; } return head; } struct snake* remove_snake(struct snake* snake) { if(snake == NULL || snake-> next == NULL) { free(snake); return NULL; } struct snake* previous = NULL; struct snake* current = NULL; while (current->next !=NULL) { previous = current; current = current->next; } if (previous !=NULL) { free(previous->next); previous->next = NULL; } }