aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Liodden <[email protected]>2018-01-18 15:50:42 +0100
committerErik Liodden <[email protected]>2018-01-18 15:50:42 +0100
commitd7a735e451a58d5c74c1cb3098d762642892cab9 (patch)
tree912a45949cf6053fe16165624031a8ef070a9435
parent8b7e2c1fedebdc9f94ad3cc6b6e9f9cfc741d92f (diff)
downloadalgdat-d7a735e451a58d5c74c1cb3098d762642892cab9.tar.gz
llist: a node points to itself after init
this makes a special case a part of the general case (yay). if the node is not part of a list it can still be used as a parameter for llist_remove_node() without giving segfaults. (it won't do anything).
-rw-r--r--llist.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/llist.c b/llist.c
index b7c18ce..3a612fe 100644
--- a/llist.c
+++ b/llist.c
@@ -15,8 +15,8 @@
static void llist_node_init(struct llist_node *node, size_t elem_size,
void (*freefn)(void *))
{
- node->prev = NULL;
- node->next = NULL;
+ node->prev = node;
+ node->next = node;
node->elem = allocate(elem_size);
node->elem_size = elem_size;
node->freefn = freefn;