src/linked_list.c

changeset 628
1e2be40f0cb5
parent 592
bb69ef3ad1f3
child 629
6c81ee4f11ad
equal deleted inserted replaced
627:cc8cbabd27cd 628:1e2be40f0cb5
30 #include "cx/utils.h" 30 #include "cx/utils.h"
31 #include <stdint.h> 31 #include <stdint.h>
32 #include <string.h> 32 #include <string.h>
33 #include <assert.h> 33 #include <assert.h>
34 34
35 /* LOW LEVEL LINKED LIST FUNCTIONS */ 35 // LOW LEVEL LINKED LIST FUNCTIONS
36 36
37 #define CX_LL_PTR(cur, off) (*(void**)(((char*)(cur))+(off))) 37 #define CX_LL_PTR(cur, off) (*(void**)(((char*)(cur))+(off)))
38 #define ll_prev(node) CX_LL_PTR(node, loc_prev) 38 #define ll_prev(node) CX_LL_PTR(node, loc_prev)
39 #define ll_next(node) CX_LL_PTR(node, loc_next) 39 #define ll_next(node) CX_LL_PTR(node, loc_next)
40 #define ll_advance(node) CX_LL_PTR(node, loc_advance) 40 #define ll_advance(node) CX_LL_PTR(node, loc_advance)
335 free(sorted); 335 free(sorted);
336 } 336 }
337 return ret; 337 return ret;
338 } 338 }
339 339
340 void cx_linked_list_sort( /* NOLINT(misc-no-recursion) - purposely recursive function */ 340 void cx_linked_list_sort( // NOLINT(misc-no-recursion) - purposely recursive function
341 void **begin, 341 void **begin,
342 void **end, 342 void **end,
343 ptrdiff_t loc_prev, 343 ptrdiff_t loc_prev,
344 ptrdiff_t loc_next, 344 ptrdiff_t loc_next,
345 ptrdiff_t loc_data, 345 ptrdiff_t loc_data,
453 *end = *begin; 453 *end = *begin;
454 } 454 }
455 *begin = prev; 455 *begin = prev;
456 } 456 }
457 457
458 /* HIGH LEVEL LINKED LIST IMPLEMENTATION */ 458 // HIGH LEVEL LINKED LIST IMPLEMENTATION
459 459
460 typedef struct cx_linked_list_node cx_linked_list_node; 460 typedef struct cx_linked_list_node cx_linked_list_node;
461 struct cx_linked_list_node { 461 struct cx_linked_list_node {
462 cx_linked_list_node *prev; 462 cx_linked_list_node *prev;
463 cx_linked_list_node *next; 463 cx_linked_list_node *next;

mercurial