src/list.c

changeset 524
e98b09018d32
parent 519
79d14e821b3a
child 525
536646d1575b
equal deleted inserted replaced
523:6a981ec4d58b 524:e98b09018d32
48 cx_foreach(void*, elem, iter) { 48 cx_foreach(void*, elem, iter) {
49 elem = list->content_destructor(elem); 49 elem = list->content_destructor(elem);
50 } 50 }
51 } 51 }
52 } 52 }
53 if (list->autofree) { 53 list->cl->destructor(list);
54 cxFree(list->allocator, list->list_destructor(list)); 54 cxFree(list->allocator, list);
55 return NULL; 55 return NULL;
56 } else {
57 return list->list_destructor(list);
58 }
59 } 56 }
60
61 void cxListMemoryMgmt(
62 CxList *list,
63 cx_destructor_func list_destructor,
64 cx_destructor_func content_destructor,
65 bool list_autofree,
66 bool content_autofree
67 ) {
68 if (list_destructor != NULL) list->list_destructor = list_destructor;
69 list->content_destructor = content_destructor;
70 list->autofree = list_autofree;
71 list->autofree_contents = content_autofree;
72 }

mercurial