]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/linklist.h
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / lib / linklist.h
index 39e70293d24bafd974afaf87f5221bef01c3861a..0475391e9f98c153f7f4b53aa6d88aa7003eb147 100644 (file)
@@ -52,7 +52,9 @@ struct list {
 };
 
 #define listnextnode(X) ((X) ? ((X)->next) : NULL)
+#define listnextnode_unchecked(X) ((X)->next)
 #define listhead(X) ((X) ? ((X)->head) : NULL)
+#define listhead_unchecked(X) ((X)->head)
 #define listtail(X) ((X) ? ((X)->tail) : NULL)
 #define listcount(X) ((X)->count)
 #define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL)
@@ -80,6 +82,19 @@ extern struct list *list_new(void);
  */
 extern void listnode_add(struct list *list, void *data);
 
+/*
+ * Add a new element to the beginning of a list.
+ *
+ * Runtime is O(1).
+ *
+ * list
+ *    list to operate on
+ *
+ * data
+ *    element to add
+ */
+extern void listnode_add_head(struct list *list, void *data);
+
 /*
  * Insert a new element into a list with insertion sort.
  *
@@ -220,20 +235,6 @@ extern struct list *list_dup(struct list *l);
 extern void list_sort(struct list *list,
                      int (*cmp)(const void **, const void **));
 
-/*
- * The usage of list_delete is being transitioned to pass in
- * the double pointer to remove use after free's.
- * list_free usage is deprecated, it leads to memory leaks
- * of the linklist nodes.  Please use list_delete_and_null
- *
- * In Oct of 2018, rename list_delete_and_null to list_delete
- * and remove list_delete_original and the list_delete #define
- * Additionally remove list_free entirely
- */
-#if defined(VERSION_TYPE_DEV) && CONFDATE > 20181001
-CPP_NOTICE("list_delete without double pointer is deprecated, please fixup")
-#endif
-
 /*
  * Delete a list and NULL its pointer.
  *
@@ -243,23 +244,7 @@ CPP_NOTICE("list_delete without double pointer is deprecated, please fixup")
  *    pointer to list pointer; this will be set to NULL after the list has been
  *    deleted
  */
-extern void list_delete_and_null(struct list **plist);
-
-/*
- * Delete a list.
- *
- * If non-null, list->del is called with each data element.
- *
- * plist
- *    pointer to list pointer
- */
-extern void list_delete_original(struct list *list);
-#define list_delete(X)                                                         \
-       list_delete_original((X))                                              \
-               CPP_WARN("Please transition to using list_delete_and_null")
-#define list_free(X)                                                           \
-       list_delete_original((X))                                              \
-               CPP_WARN("Please transition tousing list_delete_and_null")
+extern void list_delete(struct list **plist);
 
 /*
  * Delete all nodes from a list without deleting the list itself.