src/linked_list.c

changeset 662
d0d95740071b
parent 661
0a71ac9547fd
child 664
af5bf4603a5d
equal deleted inserted replaced
661:0a71ac9547fd 662:d0d95740071b
293 void *re, 293 void *re,
294 CxListComparator cmp_func 294 CxListComparator cmp_func
295 ) { 295 ) {
296 void *sbo[CX_LINKED_LIST_SORT_SBO_SIZE]; 296 void *sbo[CX_LINKED_LIST_SORT_SBO_SIZE];
297 void **sorted = length >= CX_LINKED_LIST_SORT_SBO_SIZE ? 297 void **sorted = length >= CX_LINKED_LIST_SORT_SBO_SIZE ?
298 malloc(sizeof(void *) * length) : sbo; 298 malloc(sizeof(void *) * length) : sbo;
299 if (sorted == NULL) abort(); 299 if (sorted == NULL) abort();
300 void *rc, *lc; 300 void *rc, *lc;
301 301
302 lc = ls; 302 lc = ls;
303 rc = le; 303 rc = le;
868 cx_ll_compare, 868 cx_ll_compare,
869 cx_ll_reverse, 869 cx_ll_reverse,
870 cx_ll_iterator, 870 cx_ll_iterator,
871 }; 871 };
872 872
873 CxList *cxLinkedListCreate( 873 static CxList *cx_linked_list_create(
874 CxAllocator const *allocator, 874 CxAllocator const *allocator,
875 CxListComparator comparator, 875 CxListComparator comparator,
876 size_t item_size 876 size_t item_size
877 ) { 877 ) {
878 cx_linked_list *list = cxCalloc(allocator, 1, sizeof(cx_linked_list)); 878 cx_linked_list *list = cxCalloc(allocator, 1, sizeof(cx_linked_list));
884 list->base.itemsize = item_size; 884 list->base.itemsize = item_size;
885 list->base.capacity = SIZE_MAX; 885 list->base.capacity = SIZE_MAX;
886 886
887 return (CxList *) list; 887 return (CxList *) list;
888 } 888 }
889
890 CxList *cxLinkedListCreate(
891 CxAllocator const *allocator,
892 CxListComparator comparator,
893 size_t item_size
894 ) {
895 return cx_linked_list_create(allocator, comparator, item_size);
896 }
897
898 CxList *cxLinkedListCreateSimple(size_t item_size) {
899 return cx_linked_list_create(cxDefaultAllocator, NULL, item_size);
900 }

mercurial