src/linked_list.c

changeset 1318
12fa1d37fe48
parent 1316
c41538edfcef
child 1319
aa1f580f8f59
equal deleted inserted replaced
1317:eeb2fc3850e2 1318:12fa1d37fe48
399 void **begin, 399 void **begin,
400 void **end 400 void **end
401 ) { 401 ) {
402 void *sbo[CX_LINKED_LIST_SORT_SBO_SIZE]; 402 void *sbo[CX_LINKED_LIST_SORT_SBO_SIZE];
403 void **sorted = length >= CX_LINKED_LIST_SORT_SBO_SIZE ? 403 void **sorted = length >= CX_LINKED_LIST_SORT_SBO_SIZE ?
404 malloc(sizeof(void *) * length) : sbo; 404 cxMalloc(cxDefaultAllocator, sizeof(void *) * length) : sbo;
405 if (sorted == NULL) abort(); 405 if (sorted == NULL) abort();
406 void *rc, *lc; 406 void *rc, *lc;
407 407
408 lc = ls; 408 lc = ls;
409 rc = le; 409 rc = le;
437 ll_next(sorted[length - 1]) = NULL; 437 ll_next(sorted[length - 1]) = NULL;
438 438
439 *begin = sorted[0]; 439 *begin = sorted[0];
440 *end = sorted[length - 1]; 440 *end = sorted[length - 1];
441 if (sorted != sbo) { 441 if (sorted != sbo) {
442 free(sorted); 442 cxFree(cxDefaultAllocator, sorted);
443 } 443 }
444 } 444 }
445 445
446 void cx_linked_list_sort( // NOLINT(misc-no-recursion) - purposely recursive function 446 void cx_linked_list_sort( // NOLINT(misc-no-recursion) - purposely recursive function
447 void **begin, 447 void **begin,

mercurial