]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Hide list macros in linklist.c
authorDonald Sharp <sharpd@nvidia.com>
Fri, 9 Dec 2022 13:37:45 +0000 (08:37 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 9 Dec 2022 13:38:50 +0000 (08:38 -0500)
The LISTNODE_ATTACH|DELETE macros are only used in
linklist.c.  Let's remove temptation from people
to use them.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/linklist.c
lib/linklist.h

index d1b57084ef83f838083083a8768cce156c2f8b6c..d2a29b7ed1bc9e783a4cd0fdf1956e8392749d1d 100644 (file)
 DEFINE_MTYPE_STATIC(LIB, LINK_LIST, "Link List");
 DEFINE_MTYPE_STATIC(LIB, LINK_NODE, "Link Node");
 
+/* 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)
+
+/* 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)
+
 struct list *list_new(void)
 {
        return XCALLOC(MTYPE_LINK_LIST, sizeof(struct list));
index 1452145218064457ae3cb32ae1b90c15291167d0..e7594728f149c94420ed40daaa182f451c29dd9d 100644 (file)
@@ -349,37 +349,6 @@ extern struct list *list_dup(struct list *list);
        (node) != NULL && ((data) = static_cast(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)
-
-/* 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)
-
 extern struct listnode *listnode_lookup_nocheck(struct list *list, void *data);
 
 /*