From 504d0a409627e21167233e538dbc49af59fbdd99 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Mon, 24 Jun 2019 11:37:49 -0400 Subject: lib: Add a nexthop_dup() that allocates and copies Add a nexthop_dup() api that both allocates and copies a new nexthop from an old one. Still retain the old exposed function nexthop_copy() so we can copy without allocation. Signed-off-by: Stephen Worley --- lib/nexthop.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/nexthop.h') diff --git a/lib/nexthop.h b/lib/nexthop.h index ada7317a58..20401cd581 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -152,8 +152,12 @@ extern const char *nexthop2str(const struct nexthop *nexthop, char *str, int size); extern struct nexthop *nexthop_next(struct nexthop *nexthop); extern unsigned int nexthop_level(struct nexthop *nexthop); +/* Copies to an already allocated nexthop struct */ extern void nexthop_copy(struct nexthop *copy, const struct nexthop *nexthop, struct nexthop *rparent); +/* Duplicates a nexthop and returns the newly allocated nexthop */ +extern struct nexthop *nexthop_dup(const struct nexthop *nexthop, + struct nexthop *rparent); #ifdef __cplusplus } -- cgit v1.2.3