summaryrefslogtreecommitdiffstats
path: root/lib/linklist.h
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-09-28 03:19:20 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-10-05 16:53:17 +0200
commitacdf5e25101bafe334e6b500c3dd0a2babb3c1ec (patch)
treed8b9483a3aeebc7e90ddbe5f765e5e63aecb8e1b /lib/linklist.h
parent*: Convert list_delete(struct list *) to ** to allow nulling (diff)
downloadfrr-acdf5e25101bafe334e6b500c3dd0a2babb3c1ec.tar.xz
frr-acdf5e25101bafe334e6b500c3dd0a2babb3c1ec.zip
*: Convert list_free usage to list_delete
list_free is occassionally being used to delete the list and accidently not deleting all the nodes. We keep running across this usage pattern. Let's remove the temptation and only allow list_delete to handle list deletion. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/linklist.h')
-rw-r--r--lib/linklist.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/linklist.h b/lib/linklist.h
index 5ae728ce0..4a65fead8 100644
--- a/lib/linklist.h
+++ b/lib/linklist.h
@@ -61,7 +61,6 @@ struct list {
/* 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 *);
@@ -77,16 +76,22 @@ extern void *listnode_head(struct list *);
/*
* 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 CONFDATE > 20181001
CPP_NOTICE("list_delete without double pointer is deprecated, please fixup")
#endif
extern void list_delete_and_null(struct list **);
extern void list_delete_original(struct list *);
-#define list_delete(X) list_delete_original((X)) \
+#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_all_node(struct list *);