skuska
This commit is contained in:
parent
78f05087c6
commit
abf3c910a6
@ -1,6 +1,5 @@
|
||||
#include "snake.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
struct snake* add_snake(struct snake* snake,int x,int y){
|
||||
struct snake* hlavicka = calloc(1,sizeof(struct snake));
|
||||
@ -14,7 +13,7 @@ struct snake* add_snake(struct snake* snake,int x,int y){
|
||||
}
|
||||
|
||||
struct snake* remove_snake(struct snake* snake){
|
||||
if (snake == NULL) {
|
||||
if (snake == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -25,11 +24,13 @@ struct snake* remove_snake(struct snake* snake){
|
||||
if (nova_hlavicka == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct snake* chvost = nova_hlavicka;
|
||||
while (chvost->next != NULL) {
|
||||
chvost = chvost->next;
|
||||
}
|
||||
assert(chvost->next == NULL);
|
||||
|
||||
chvost->next = NULL;
|
||||
|
||||
return nova_hlavicka;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user