opsoiewjoiwerewr
This commit is contained in:
parent
abf3c910a6
commit
df7d0ccd00
24
cv9/snake.c
24
cv9/snake.c
@ -13,26 +13,22 @@ 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){
|
||||||
if (snake == NULL) {
|
|
||||||
|
if (snake == NULL || snake->next == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct snake* nova_hlavicka = snake->next;
|
struct snake* prev = NULL;
|
||||||
|
struct snake* current = snake;
|
||||||
free(snake);
|
while (current->next != NULL) {
|
||||||
|
prev = current;
|
||||||
if (nova_hlavicka == NULL) {
|
current = current->next;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct snake* chvost = nova_hlavicka;
|
free(current);
|
||||||
while (chvost->next != NULL) {
|
prev->next = NULL;
|
||||||
chvost = chvost->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
chvost->next = NULL;
|
return snake;
|
||||||
|
|
||||||
return nova_hlavicka;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_snake(struct snake* sn){
|
void free_snake(struct snake* sn){
|
||||||
|
Loading…
Reference in New Issue
Block a user