summaryrefslogtreecommitdiffstats
path: root/lib/linklist.h
diff options
context:
space:
mode:
authorwhitespace / reindent <invalid@invalid.invalid>2017-07-17 14:03:14 +0200
committerwhitespace / reindent <invalid@invalid.invalid>2017-07-17 14:04:07 +0200
commitd62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch)
tree3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /lib/linklist.h
parent*: add indent control files (diff)
downloadfrr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.tar.xz
frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.zip
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/linklist.h')
-rw-r--r--lib/linklist.h145
1 files changed, 73 insertions, 72 deletions
diff --git a/lib/linklist.h b/lib/linklist.h
index 37ba396a7..9bd6e3849 100644
--- a/lib/linklist.h
+++ b/lib/linklist.h
@@ -24,33 +24,31 @@
/* listnodes must always contain data to be valid. Adding an empty node
* to a list is invalid
*/
-struct listnode
-{
- struct listnode *next;
- struct listnode *prev;
-
- /* private member, use getdata() to retrieve, do not access directly */
- void *data;
+struct listnode {
+ struct listnode *next;
+ struct listnode *prev;
+
+ /* private member, use getdata() to retrieve, do not access directly */
+ void *data;
};
-struct list
-{
- struct listnode *head;
- struct listnode *tail;
+struct list {
+ struct listnode *head;
+ struct listnode *tail;
- /* invariant: count is the number of listnodes in the list */
- unsigned int count;
+ /* invariant: count is the number of listnodes in the list */
+ unsigned int count;
- /*
- * Returns -1 if val1 < val2, 0 if equal?, 1 if val1 > val2.
- * Used as definition of sorted for listnode_add_sort
- */
- int (*cmp) (void *val1, void *val2);
+ /*
+ * Returns -1 if val1 < val2, 0 if equal?, 1 if val1 > val2.
+ * Used as definition of sorted for listnode_add_sort
+ */
+ int (*cmp)(void *val1, void *val2);
- /* callback to free user-owned data when listnode is deleted. supplying
- * this callback is very much encouraged!
- */
- void (*del) (void *val);
+ /* callback to free user-owned data when listnode is deleted. supplying
+ * this callback is very much encouraged!
+ */
+ void (*del)(void *val);
};
#define listnextnode(X) ((X) ? ((X)->next) : NULL)
@@ -61,36 +59,39 @@ struct list
#define listgetdata(X) (assert((X)->data != NULL), (X)->data)
/* Prototypes. */
-extern struct list *list_new(void); /* encouraged: set list.del callback on new lists */
-extern void list_free (struct list *);
-
-extern void listnode_add (struct list *, void *);
-extern void listnode_add_sort (struct list *, void *);
-extern struct listnode *listnode_add_after (struct list *, struct listnode *, void *);
-extern struct listnode *listnode_add_before (struct list *, struct listnode *, void *);
-extern void listnode_move_to_tail (struct list *, struct listnode *);
-extern void listnode_delete (struct list *, void *);
-extern struct listnode *listnode_lookup (struct list *, void *);
-extern void *listnode_head (struct list *);
-
-extern void list_delete (struct list *);
-extern void list_delete_all_node (struct list *);
+extern struct list *
+list_new(void); /* encouraged: set list.del callback on new lists */
+extern void list_free(struct list *);
+
+extern void listnode_add(struct list *, void *);
+extern void listnode_add_sort(struct list *, void *);
+extern struct listnode *listnode_add_after(struct list *, struct listnode *,
+ void *);
+extern struct listnode *listnode_add_before(struct list *, struct listnode *,
+ void *);
+extern void listnode_move_to_tail(struct list *, struct listnode *);
+extern void listnode_delete(struct list *, void *);
+extern struct listnode *listnode_lookup(struct list *, void *);
+extern void *listnode_head(struct list *);
+
+extern void list_delete(struct list *);
+extern void list_delete_all_node(struct list *);
/* For ospfd and ospf6d. */
-extern void list_delete_node (struct list *, struct listnode *);
+extern void list_delete_node(struct list *, struct listnode *);
/* For ospf_spf.c */
-extern void list_add_list (struct list *, struct list *);
+extern void list_add_list(struct list *, struct list *);
-/* List iteration macro.
+/* List iteration macro.
* Usage: for (ALL_LIST_ELEMENTS (...) { ... }
* It is safe to delete the listnode using this macro.
*/
-#define ALL_LIST_ELEMENTS(list,node,nextnode,data) \
- (node) = listhead(list), ((data) = NULL); \
- (node) != NULL && \
- ((data) = listgetdata(node),(nextnode) = node->next, 1); \
- (node) = (nextnode), ((data) = NULL)
+#define ALL_LIST_ELEMENTS(list, node, nextnode, data) \
+ (node) = listhead(list), ((data) = NULL); \
+ (node) != NULL \
+ && ((data) = listgetdata(node), (nextnode) = node->next, 1); \
+ (node) = (nextnode), ((data) = NULL)
/* read-only list iteration macro.
* Usage: as per ALL_LIST_ELEMENTS, but not safe to delete the listnode Only
@@ -98,40 +99,40 @@ extern void list_add_list (struct list *, struct list *);
* deleted in the body of the loop. Does not have forward-reference overhead
* of previous macro.
*/
-#define ALL_LIST_ELEMENTS_RO(list,node,data) \
- (node) = listhead(list), ((data) = NULL);\
- (node) != NULL && ((data) = listgetdata(node), 1); \
- (node) = listnextnode(node), ((data) = NULL)
+#define ALL_LIST_ELEMENTS_RO(list, node, data) \
+ (node) = listhead(list), ((data) = NULL); \
+ (node) != NULL && ((data) = listgetdata(node), 1); \
+ (node) = listnextnode(node), ((data) = NULL)
/* these *do not* cleanup list nodes and referenced data, as the functions
* do - these macros simply {de,at}tach a listnode from/to a list.
*/
-
+
/* List node attach macro. */
-#define LISTNODE_ATTACH(L,N) \
- do { \
- (N)->prev = (L)->tail; \
- (N)->next = NULL; \
- if ((L)->head == NULL) \
- (L)->head = (N); \
- else \
- (L)->tail->next = (N); \
- (L)->tail = (N); \
- (L)->count++; \
- } while (0)
+#define LISTNODE_ATTACH(L, N) \
+ do { \
+ (N)->prev = (L)->tail; \
+ (N)->next = NULL; \
+ if ((L)->head == NULL) \
+ (L)->head = (N); \
+ else \
+ (L)->tail->next = (N); \
+ (L)->tail = (N); \
+ (L)->count++; \
+ } while (0)
/* List node detach macro. */
-#define LISTNODE_DETACH(L,N) \
- do { \
- if ((N)->prev) \
- (N)->prev->next = (N)->next; \
- else \
- (L)->head = (N)->next; \
- if ((N)->next) \
- (N)->next->prev = (N)->prev; \
- else \
- (L)->tail = (N)->prev; \
- (L)->count--; \
- } while (0)
+#define LISTNODE_DETACH(L, N) \
+ do { \
+ if ((N)->prev) \
+ (N)->prev->next = (N)->next; \
+ else \
+ (L)->head = (N)->next; \
+ if ((N)->next) \
+ (N)->next->prev = (N)->prev; \
+ else \
+ (L)->tail = (N)->prev; \
+ (L)->count--; \
+ } while (0)
#endif /* _ZEBRA_LINKLIST_H */