diff options
author | pgen <p.gen.progs@gmail.com> | 2022-04-03 21:10:21 +0200 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2022-04-03 21:10:21 +0200 |
commit | 531a34106187bf50af0459e54683b837f6858bd6 (patch) | |
tree | e70879d10477983a66bf4a945bef4499d288fbf0 /list.c | |
parent | 2bcbdec7eb4d36c931ae85d7dfe720dcca91cea2 (diff) |
Some code simplifications
Diffstat (limited to 'list.c')
-rw-r--r-- | list.c | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -28,7 +28,7 @@ ll_partition(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), static void ll_quicksort(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), - void (*swap)(void * a, void *)); + void (*swap)(void *, void *)); /* ========================== */ /* Creates a new linked list. */ @@ -59,9 +59,7 @@ ll_init(ll_t * list) ll_node_t * ll_new_node(void) { - ll_node_t * ret = xmalloc(sizeof(ll_node_t)); - - return ret; + return xmalloc(sizeof(ll_node_t)); } /* ====================================================================== */ @@ -224,7 +222,7 @@ ll_partition(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), /* ======================================================== */ static void ll_quicksort(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), - void (*swap)(void * a, void *)) + void (*swap)(void *, void *)) { if (h != NULL && l != h && l != h->next) { @@ -238,8 +236,7 @@ ll_quicksort(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), /* A linked list sort function. */ /* ============================ */ void -ll_sort(ll_t * list, int (*comp)(void *, void *), - void (*swap)(void * a, void *)) +ll_sort(ll_t * list, int (*comp)(void *, void *), void (*swap)(void *, void *)) { /* Call the recursive ll_quicksort function. */ /* """"""""""""""""""""""""""""""""""""""""" */ @@ -254,10 +251,10 @@ ll_delete(ll_t * const list, ll_node_t * node) { if (list->head == list->tail) { - if (list->head != NULL) - list->head = list->tail = NULL; - else + if (list->head == NULL) return 0; + + list->head = list->tail = NULL; } else if (node->prev == NULL) { @@ -289,7 +286,7 @@ ll_delete(ll_t * const list, ll_node_t * node) /* ==========================================================================*/ ll_node_t * ll_find(ll_t * const list, void * const data, - int (*cmpfunc)(const void * a, const void * b)) + int (*cmpfunc)(const void *, const void *)) { ll_node_t * node; |