7 struct list
*list_append(void *el
, struct list
*head
)
10 return list_cons(el
, NULL
);
11 struct list
*tail
= head
;
12 while (tail
->tail
!= NULL
)
14 tail
->tail
= list_cons(el
, NULL
);
18 struct list
*list_cons(void *el
, struct list
*tail
)
20 struct list
*res
= safe_malloc(sizeof(struct list
));
26 void list_free(struct list
*head
, void (*freefun
)(void *))
28 while (head
!= NULL
) {
29 struct list
*t
= head
;
37 void **list_to_array(struct list
*list
, int *num
, bool reverse
)
39 int i
= list_length(list
);
41 void **ptr
= safe_malloc(i
*sizeof(void *));
43 struct list
*r
= list
;
48 ptr
[*num
-(--i
)-1] = r
->el
;
56 int list_length(struct list
*r
)