In the init()
function, you are doing
memset(ftt->foods,0,sizeof(struct ftt_list));
This will overwrite members of ftt->foods
so you will loose memory allocated to ftt->foods->head
.
So when you try to access ftt->foods->head->data
you are accessing null pointer ftt->foods->head
.
You should memset()
before malloc()
or rather use calloc()
.