summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2019-03-28 17:59:27 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2019-03-29 15:04:17 +0100
commit2fe55afeec519afbe4fac45c0d0b8d4331f623aa (patch)
tree3e850f5813a5e5551b5a4a64adf02c2be8be89cf
parent3e3708cbd38a8e25c2cf8bede4ea1c86a0911dac (diff)
lib: add lookup utility routine that accepts null list values
lists passed as parameter that are null, are accepted by the function. I would even propose to silently return NULL in official listnode_lookup() routine. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
-rw-r--r--lib/linklist.c7
-rw-r--r--lib/linklist.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/linklist.c b/lib/linklist.c
index 3aa7cae8b7..b8d9a47d2a 100644
--- a/lib/linklist.c
+++ b/lib/linklist.c
@@ -259,6 +259,13 @@ struct listnode *listnode_lookup(struct list *list, void *data)
return NULL;
}
+struct listnode *listnode_lookup_nocheck(struct list *list, void *data)
+{
+ if (!list)
+ return NULL;
+ return listnode_lookup(list, data);
+}
+
void list_delete_node(struct list *list, struct listnode *node)
{
if (node->prev)
diff --git a/lib/linklist.h b/lib/linklist.h
index 76fad45d08..aac3179fbb 100644
--- a/lib/linklist.h
+++ b/lib/linklist.h
@@ -341,6 +341,8 @@ extern void list_add_list(struct list *list, struct list *add);
(L)->count--; \
} while (0)
+extern struct listnode *listnode_lookup_nocheck(struct list *list, void *data);
+
#ifdef __cplusplus
}
#endif