diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2020-08-10 23:21:59 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2020-08-11 20:41:44 -0300 |
| commit | 0f16688138d40affba369a6e2f394b3a5d4c3bb4 (patch) | |
| tree | 45ca51783536254928f3ef871beffdc747933837 /lib/linklist.c | |
| parent | e26e2c15e9e5b7a61512a789a25809038805db47 (diff) | |
lib: introduce new list_dup() API
This new function will be used by the upcoming TI-LFA code.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/linklist.c')
| -rw-r--r-- | lib/linklist.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/linklist.c b/lib/linklist.c index 2936c5b502..84dc6e1419 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -150,6 +150,23 @@ bool listnode_add_sort_nodup(struct list *list, void *val) return true; } +struct list *list_dup(struct list *list) +{ + struct list *dup; + struct listnode *node; + void *data; + + assert(list); + + dup = list_new(); + dup->cmp = list->cmp; + dup->del = list->del; + for (ALL_LIST_ELEMENTS_RO(list, node, data)) + listnode_add(dup, data); + + return dup; +} + void listnode_add_sort(struct list *list, void *val) { struct listnode *n; |
