You have to allocate memory for a structure before you use a pointer to it to access its members. Change your function empty_dllist
to -
dllist *empty_dllist(void) {
dllist *l = malloc(sizeof *l);
if(l == NULL) {
// failed to allocate memory
// handle it
// return NULL
}
l->head = NULL;
l->tail = NULL;
return l;
}