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 } |
|