26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 */ |
27 */ |
28 |
28 |
29 #include "cx/list.h" |
29 #include "cx/list.h" |
30 |
30 |
31 CxList *cxListDestroy(CxList *list) { |
31 void cxListDestroy(CxList *list) { |
32 if (list->content_destructor != NULL) { |
32 switch (list->content_destructor_type) { |
33 CxIterator iter = cxListBegin(list); |
33 case CX_DESTRUCTOR_SIMPLE: { |
34 cx_foreach(void*, elem, iter) { |
34 CxIterator iter = cxListBegin(list); |
35 list->content_destructor(elem); |
35 cx_foreach(void*, elem, iter) { |
|
36 list->simple_destructor(elem); |
|
37 } |
|
38 break; |
36 } |
39 } |
|
40 case CX_DESTRUCTOR_ADVANCED: { |
|
41 CxIterator iter = cxListBegin(list); |
|
42 cx_foreach(void*, elem, iter) { |
|
43 list->advanced_destructor.func(list->advanced_destructor.data, elem); |
|
44 } |
|
45 break; |
|
46 } |
|
47 case CX_DESTRUCTOR_NONE: |
|
48 break; // nothing |
37 } |
49 } |
|
50 |
38 list->cl->destructor(list); |
51 list->cl->destructor(list); |
39 cxFree(list->allocator, list); |
52 cxFree(list->allocator, list); |
40 return NULL; |
|
41 } |
53 } |