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>
This commit is contained in:
Philippe Guibert 2019-03-28 17:59:27 +01:00
parent 3e3708cbd3
commit 2fe55afeec
2 changed files with 9 additions and 0 deletions

View File

@ -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)

View File

@ -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