summaryrefslogtreecommitdiffstats
path: root/list.c
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2020-11-13 23:29:23 +0100
committerpgen <p.gen.progs@gmail.com>2020-11-13 23:57:46 +0100
commit97ee2fbf897a589c861b9379b41f8b9a70855cf5 (patch)
tree1cb9ab216d4554aac0d5eba501fec8da2ed0388a /list.c
parent0e6328f3f08945d04d565d78cd413e9c355fb1f0 (diff)
Improve comments
Diffstat (limited to 'list.c')
-rw-r--r--list.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/list.c b/list.c
index 2b0d405..4c0973c 100644
--- a/list.c
+++ b/list.c
@@ -10,7 +10,7 @@
/* will not try to allocate or free this data pointer. */
/* */
/* Also accessors are not provided, the user has to directly manipulate */
-/* the structure members (head, tail, len, data, prev, next) */
+/* the structure members (head, tail, len, data, prev, next). */
/* ********************************************************************* */
#include <stdio.h>
@@ -26,9 +26,9 @@ static ll_node_t *
ll_partition(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *),
void (*swap)(void *, void *));
-/* ========================= */
-/* Creates a new linked list */
-/* ========================= */
+/* ========================== */
+/* Creates a new linked list. */
+/* ========================== */
ll_t *
ll_new(void)
{
@@ -38,9 +38,9 @@ ll_new(void)
return ret;
}
-/* ========================= */
-/* Initializes a linked list */
-/* ========================= */
+/* ========================== */
+/* Initializes a linked list. */
+/* ========================== */
void
ll_init(ll_t * list)
{
@@ -49,9 +49,9 @@ ll_init(ll_t * list)
list->len = 0;
}
-/* ===================================================== */
-/* Allocates the space for a new node in the linked list */
-/* ===================================================== */
+/* ====================================================== */
+/* Allocates the space for a new node in the linked list. */
+/* ====================================================== */
ll_node_t *
ll_new_node(void)
{
@@ -60,12 +60,12 @@ ll_new_node(void)
return ret;
}
-/* ===================================================================== */
-/* Appends a new node filled with its data at the end of the linked list */
-/* The user is responsible for the memory management of the data. */
-/* */
-/* Note: list is assumed to be initialized by ll_new(). */
-/* ===================================================================== */
+/* ====================================================================== */
+/* Appends a new node filled with its data at the end of the linked list. */
+/* The user is responsible for the memory management of the data. */
+/* */
+/* Note: list is assumed to be initialized by ll_new(). */
+/* ====================================================================== */
void
ll_append(ll_t * const list, void * const data)
{
@@ -121,9 +121,9 @@ ll_prepend(ll_t * const list, void * const data)
#endif
#if 0
-/* ======================================================== */
-/* Inserts a new node before the specified node in the list */
-/* ======================================================== */
+/* ========================================================= */
+/* Inserts a new node before the specified node in the list. */
+/* ========================================================= */
void
ll_insert_before(ll_t * const list, ll_node_t * node, void * const data)
{
@@ -149,9 +149,9 @@ ll_insert_before(ll_t * const list, ll_node_t * node, void * const data)
#endif
#if 0
-/* ======================================================= */
-/* Inserts a new node after the specified node in the list */
-/* ======================================================= */
+/* ======================================================== */
+/* Inserts a new node after the specified node in the list. */
+/* ======================================================== */
void
ll_insert_after(ll_t * const list, ll_node_t * node, void * const data)
{
@@ -177,7 +177,7 @@ ll_insert_after(ll_t * const list, ll_node_t * node, void * const data)
#endif
/* ====================================================== */
-/* Partition code for the quicksort function */
+/* Partition code for the quicksort function. */
/* Based on code found here: */
/* http://www.geeksforgeeks.org/quicksort-for-linked-list */
/* ====================================================== */
@@ -187,11 +187,11 @@ ll_partition(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *),
{
/* Considers last element as pivot, places the pivot element at its */
/* correct position in sorted array, and places all smaller (smaller than */
- /* pivot) to left of pivot and all greater elements to right of pivot */
+ /* pivot) to left of pivot and all greater elements to right of pivot. */
/* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
- /* Set pivot as h element */
- /* """""""""""""""""""""" */
+ /* Set pivot as h element. */
+ /* """"""""""""""""""""""" */
void * x = h->data;
ll_node_t * i = l->prev;
@@ -213,9 +213,9 @@ ll_partition(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *),
return i;
}
-/* ======================================================= */
-/* A recursive implementation of quicksort for linked list */
-/* ======================================================= */
+/* ======================================================== */
+/* A recursive implementation of quicksort for linked list. */
+/* ======================================================== */
void
ll_quicksort(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *),
void (*swap)(void * a, void *))
@@ -228,21 +228,21 @@ ll_quicksort(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *),
}
}
-/* =========================== */
-/* A linked list sort function */
-/* =========================== */
+/* ============================ */
+/* A linked list sort function. */
+/* ============================ */
void
ll_sort(ll_t * list, int (*comp)(void *, void *),
void (*swap)(void * a, void *))
{
- /* Call the recursive ll_quicksort function */
- /* """""""""""""""""""""""""""""""""""""""" */
+ /* Call the recursive ll_quicksort function. */
+ /* """"""""""""""""""""""""""""""""""""""""" */
ll_quicksort(list->head, list->tail, comp, swap);
}
-/* ================================= */
-/* Removes a node from a linked list */
-/* ================================= */
+/* ================================== */
+/* Removes a node from a linked list. */
+/* ================================== */
int
ll_delete(ll_t * const list, ll_node_t * node)
{