src/linked_list.c

changeset 670
4ad8ea3aee49
parent 667
2f88a7c13a28
child 677
b09aae58bba4
equal deleted inserted replaced
669:dce9b8450656 670:4ad8ea3aee49
923 cx_ll_compare, 923 cx_ll_compare,
924 cx_ll_reverse, 924 cx_ll_reverse,
925 cx_ll_iterator, 925 cx_ll_iterator,
926 }; 926 };
927 927
928 static CxList *cx_linked_list_create( 928 CxList *cxLinkedListCreate(
929 CxAllocator const *allocator, 929 CxAllocator const *allocator,
930 CxListComparator comparator, 930 CxListComparator comparator,
931 size_t item_size 931 size_t item_size
932 ) { 932 ) {
933 if (allocator == NULL) {
934 allocator = cxDefaultAllocator;
935 }
936
933 cx_linked_list *list = cxCalloc(allocator, 1, sizeof(cx_linked_list)); 937 cx_linked_list *list = cxCalloc(allocator, 1, sizeof(cx_linked_list));
934 if (list == NULL) return NULL; 938 if (list == NULL) return NULL;
935 939
936 list->base.cl = &cx_linked_list_class; 940 list->base.cl = &cx_linked_list_class;
937 list->base.allocator = allocator; 941 list->base.allocator = allocator;
944 cxListStorePointers((CxList *) list); 948 cxListStorePointers((CxList *) list);
945 } 949 }
946 950
947 return (CxList *) list; 951 return (CxList *) list;
948 } 952 }
949
950 CxList *cxLinkedListCreate(
951 CxAllocator const *allocator,
952 CxListComparator comparator,
953 size_t item_size
954 ) {
955 return cx_linked_list_create(allocator, comparator, item_size);
956 }
957
958 CxList *cxLinkedListCreateSimple(size_t item_size) {
959 return cx_linked_list_create(cxDefaultAllocator, NULL, item_size);
960 }

mercurial