lib: allow caller to provide prefix storage in sockunion2hostprefix

Avoids a dynamic allocation which is usually freed immediate afterwards.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index cea430c..9765096 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -304,28 +304,27 @@
 bgp_update_address (struct interface *ifp, const union sockunion *dst,
 		    union sockunion *addr)
 {
-  struct prefix *p, *sel, *d;
+  struct prefix *p, *sel, d;
   struct connected *connected;
   struct listnode *node;
   int common;
 
-  d = sockunion2hostprefix (dst);
+  sockunion2hostprefix (dst, &d);
   sel = NULL;
   common = -1;
 
   for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
     {
       p = connected->address;
-      if (p->family != d->family)
+      if (p->family != d.family)
 	continue;
-      if (prefix_common_bits (p, d) > common)
+      if (prefix_common_bits (p, &d) > common)
 	{
 	  sel = p;
-	  common = prefix_common_bits (sel, d);
+	  common = prefix_common_bits (sel, &d);
 	}
     }
 
-  prefix_free (d);
   if (!sel)
     return 1;