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