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.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/nexthop.c') diff --git a/lib/nexthop.c b/lib/nexthop.c index 405db6a5cb..0984c1a168 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -442,6 +442,15 @@ void nexthop_copy(struct nexthop *copy, const struct nexthop *nexthop, &nexthop->nh_label->label[0]); } +struct nexthop *nexthop_dup(const struct nexthop *nexthop, + struct nexthop *rparent) +{ + struct nexthop *new = nexthop_new(); + + nexthop_copy(new, nexthop, rparent); + return new; +} + /* * nexthop printing variants: * %pNHvv -- cgit v1.2.3