aboutsummaryrefslogtreecommitdiff
path: root/src/core/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/list.c')
-rw-r--r--src/core/list.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/core/list.c b/src/core/list.c
index eb3f73d2..69a74db6 100644
--- a/src/core/list.c
+++ b/src/core/list.c
@@ -1,29 +1,27 @@
-/*
- * Copyright 2016 Garrett D'Amore <garrett@damore.org>
- *
- * This software is supplied under the terms of the MIT License, a
- * copy of which should be located in the distribution where this
- * file was obtained (LICENSE.txt). A copy of the license may also be
- * found online at https://opensource.org/licenses/MIT.
- */
+//
+// Copyright 2016 Garrett D'Amore <garrett@damore.org>
+//
+// This software is supplied under the terms of the MIT License, a
+// copy of which should be located in the distribution where this
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
#include <stdlib.h>
#include <string.h>
#include "core/nng_impl.h"
-/*
- * Linked list implementation. We implement a doubly linked list.
- * Using pointer arithmetic, we can operate as a list of "anything".
- */
+// Linked list implementation. We implement a doubly linked list.
+// Using pointer arithmetic, we can operate as a list of "anything".
#define NODE(list, item) \
- (nni_list_node_t *) (void *) (((char *) item) + list->ll_offset)
+ (nni_list_node *) (void *) (((char *) item) + list->ll_offset)
#define ITEM(list, node) \
(void *) (((char *) node) - list->ll_offset)
void
-nni_list_init_offset(nni_list_t *list, size_t offset)
+nni_list_init_offset(nni_list *list, size_t offset)
{
list->ll_offset = offset;
list->ll_head.ln_next = &list->ll_head;
@@ -32,9 +30,9 @@ nni_list_init_offset(nni_list_t *list, size_t offset)
void *
-nni_list_first(nni_list_t *list)
+nni_list_first(nni_list *list)
{
- nni_list_node_t *node = list->ll_head.ln_next;
+ nni_list_node *node = list->ll_head.ln_next;
if (node == &list->ll_head) {
return (NULL);
@@ -44,9 +42,9 @@ nni_list_first(nni_list_t *list)
void *
-nni_list_last(nni_list_t *list)
+nni_list_last(nni_list *list)
{
- nni_list_node_t *node = list->ll_head.ln_prev;
+ nni_list_node *node = list->ll_head.ln_prev;
if (node == &list->ll_head) {
return (NULL);
@@ -56,9 +54,9 @@ nni_list_last(nni_list_t *list)
void
-nni_list_append(nni_list_t *list, void *item)
+nni_list_append(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
node->ln_prev = list->ll_head.ln_prev;
node->ln_next = &list->ll_head;
@@ -68,9 +66,9 @@ nni_list_append(nni_list_t *list, void *item)
void
-nni_list_prepend(nni_list_t *list, void *item)
+nni_list_prepend(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
node->ln_next = list->ll_head.ln_next;
node->ln_prev = &list->ll_head;
@@ -80,9 +78,9 @@ nni_list_prepend(nni_list_t *list, void *item)
void *
-nni_list_next(nni_list_t *list, void *item)
+nni_list_next(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
if ((node = node->ln_next) == &list->ll_head) {
return (NULL);
@@ -92,9 +90,9 @@ nni_list_next(nni_list_t *list, void *item)
void *
-nni_list_prev(nni_list_t *list, void *item)
+nni_list_prev(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
if ((node = node->ln_prev) == &list->ll_head) {
return (NULL);
@@ -104,9 +102,9 @@ nni_list_prev(nni_list_t *list, void *item)
void
-nni_list_remove(nni_list_t *list, void *item)
+nni_list_remove(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
node->ln_prev->ln_next = node->ln_next;
node->ln_next->ln_prev = node->ln_prev;
@@ -114,9 +112,9 @@ nni_list_remove(nni_list_t *list, void *item)
void
-nni_list_node_init(nni_list_t *list, void *item)
+nni_list_node_init(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
node->ln_prev = node->ln_next = NULL;
}