Compare commits
2 Commits
6f4ea44c71
...
32d35323f9
Author | SHA1 | Date | |
---|---|---|---|
32d35323f9 | |||
c141e7e44e |
18
cv9/snake.c
18
cv9/snake.c
@ -3,10 +3,7 @@
|
|||||||
|
|
||||||
struct snake* add_snake(struct snake* snake,int x,int y){
|
struct snake* add_snake(struct snake* snake,int x,int y){
|
||||||
struct snake* hlavicka = calloc(1,sizeof(struct snake));
|
struct snake* hlavicka = calloc(1,sizeof(struct snake));
|
||||||
if (hlavicka == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
hlavicka->x = x;
|
hlavicka->x = x;
|
||||||
hlavicka->y = y;
|
hlavicka->y = y;
|
||||||
|
|
||||||
@ -16,7 +13,18 @@ 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){
|
||||||
return NULL;
|
if (snake == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct snake* nova_hlavicka = snake->next;
|
||||||
|
free(snake);
|
||||||
|
|
||||||
|
if (nova_hlavicka != NULL) {
|
||||||
|
nova_hlavicka->next = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nova_hlavicka;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_snake(struct snake* sn){
|
void free_snake(struct snake* sn){
|
||||||
|
Loading…
Reference in New Issue
Block a user