321 n++; |
322 n++; |
322 } |
323 } |
323 |
324 |
324 // Update pointer |
325 // Update pointer |
325 if (loc_prev >= 0) ll_prev(sorted[0]) = NULL; |
326 if (loc_prev >= 0) ll_prev(sorted[0]) = NULL; |
326 for (size_t i = 0; i < length - 1; i++) { |
327 cx_for_n (i, length - 1) { |
327 cx_linked_list_link(sorted[i], sorted[i + 1], loc_prev, loc_next); |
328 cx_linked_list_link(sorted[i], sorted[i + 1], loc_prev, loc_next); |
328 } |
329 } |
329 ll_next(sorted[length - 1]) = NULL; |
330 ll_next(sorted[length - 1]) = NULL; |
330 |
331 |
331 void *ret = sorted[0]; |
332 void *ret = sorted[0]; |
816 size_t num_items, |
817 size_t num_items, |
817 void const *array |
818 void const *array |
818 ) { |
819 ) { |
819 CxList *list = cxLinkedListCreate(allocator, comparator, item_size); |
820 CxList *list = cxLinkedListCreate(allocator, comparator, item_size); |
820 if (list == NULL) return NULL; |
821 if (list == NULL) return NULL; |
821 for (size_t i = 0; i < num_items; i++) { |
822 cx_for_n (i, num_items) { |
822 if (0 != cxListAdd(list, ((const unsigned char *) array) + i * item_size)) { |
823 if (0 != cxListAdd(list, ((const unsigned char *) array) + i * item_size)) { |
823 return cx_ll_default_destructor(list); |
824 return cx_ll_default_destructor(list); |
824 } |
825 } |
825 } |
826 } |
826 return list; |
827 return list; |