From 558d1fec11749d3257e32561d45b5c1ec0622cf4 Mon Sep 17 00:00:00 2001 From: "Jorge Boncompte [DTI2]" Date: Mon, 7 May 2012 16:53:05 +0000 Subject: bgpd: reduce struct attr_extra allocations/freeing Try to use on stack structs for temporary uses. Signed-off-by: Jorge Boncompte [DTI2] Signed-off-by: David Lamparter --- bgpd/bgp_attr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bgpd/bgp_attr.c') diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index b63ac4c8..2d82acc2 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -319,10 +319,14 @@ bgp_attr_extra_get (struct attr *attr) void bgp_attr_dup (struct attr *new, struct attr *orig) { + struct attr_extra *extra = new->extra; + *new = *orig; if (orig->extra) { - new->extra = bgp_attr_extra_new(); + /* if caller provided attr_extra space use it */ + if (! extra) + new->extra = bgp_attr_extra_new(); *new->extra = *orig->extra; } } -- cgit v1.2.1