diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-03-28 18:06:51 +0100 |
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2019-03-29 15:04:49 +0100 |
| commit | 33bca8a15158198eb46cc92a9be7f3b096d64b90 (patch) | |
| tree | 313ff3bd09765484bb4e7e5cc89d15fb41b8e485 /lib/linklist.c | |
| parent | e0c7edb0cb5af3f33b02668a77d320feee502d3e (diff) | |
lib: add listnode_add_force utility routine
that routine does the same as listnode_add; in addition it creates the
linked list if needed.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib/linklist.c')
| -rw-r--r-- | lib/linklist.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/linklist.c b/lib/linklist.c index b8d9a47d2a..f0d0c29245 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -325,3 +325,10 @@ void list_sort(struct list *list, int (*cmp)(const void **, const void **)) XFREE(MTYPE_TMP, items); } + +void listnode_add_force(struct list **list, void *val) +{ + if (*list == NULL) + *list = list_new(); + return listnode_add(*list, val); +} |
