2005-05-19 Paul Jakma <paul@dishone.st>

	* bgp_network.c: (bgp_accept) use XSTRDUP
	* bgpd.c: (peer_delete) XFREE the correct memtype, not free.
	  (peer_create) use XSTRDUP
	* bgp_packet.c: (bgp_stream_dup) deleted, stream_dup should be used
	  (various) update -> s/bgp_stream_dup/stream_dup
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 02ca213..25c4e37 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -2,9 +2,15 @@
 
 	* bgp_fsm.c: (bgp_stop) use sockunion_free, not XFREE..
 	* bgp_network.c: (bgp_getsockname) ditto
+	  (bgp_accept) use XSTRDUP
 	* bgp_routemap.c: (route_match_peer) ditto, als use a ret value and
 	  remove one sockunion_free.
-	* bgpd.c: (peer_delete) ditto
+	* bgpd.c: (peer_delete) ditto.
+	  XFREE the correct memtype, not free.
+	  (peer_create) use XSTRDUP
+	* bgp_packet.c: (bgp_stream_dup) deleted, stream_dup should be used
+	  (various) update -> s/bgp_stream_dup/stream_dup
+	  
 
 2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index b2708e7..fb6b64d 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -112,7 +112,7 @@
 
     /* Make peer's address string. */
     sockunion2str (&su, buf, SU_ADDRSTRLEN);
-    peer->host = strdup (buf);
+    peer->host = XSTRDUP (MTYPE_BGP_PEER_HOST, buf);
   }
 
   BGP_EVENT_ADD (peer, TCP_connection_open);
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 9fa23e5..a5fc749 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -99,22 +99,6 @@
   stream_free (stream_fifo_pop (peer->obuf));
 }
 
-/* Duplicate packet. */
-struct stream *
-bgp_packet_dup (struct stream *s)
-{
-  struct stream *new;
-
-  new = stream_new (stream_get_endp (s));
-
-  new->endp = s->endp;
-  new->getp = s->getp;
-
-  memcpy (new->data, s->data, stream_get_endp (s));
-
-  return new;
-}
-
 /* Check file descriptor whether connect is established. */
 static void
 bgp_connect_check (struct peer *peer)
@@ -232,7 +216,7 @@
   if (! stream_empty (s))
     {
       bgp_packet_set_size (s);
-      packet = bgp_packet_dup (s);
+      packet = stream_dup (s);
       bgp_packet_add (peer, packet);
       BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
       stream_reset (s);
@@ -279,7 +263,7 @@
     }
 
   bgp_packet_set_size (s);
-  packet = bgp_packet_dup (s);
+  packet = stream_dup (s);
   bgp_packet_add (peer, packet);
   stream_free (s);
   return packet;
@@ -359,7 +343,7 @@
 	  stream_putw (s, 0);
 	}
       bgp_packet_set_size (s);
-      packet = bgp_packet_dup (s);
+      packet = stream_dup (s);
       bgp_packet_add (peer, packet);
       stream_reset (s);
       return packet;
@@ -423,7 +407,7 @@
   /* Set size. */
   bgp_packet_set_size (s);
 
-  packet = bgp_packet_dup (s);
+  packet = stream_dup (s);
   stream_free (s);
 
   /* Dump packet if debug option is set. */
@@ -502,7 +486,7 @@
 
   bgp_packet_set_size (s);
 
-  packet = bgp_packet_dup (s);
+  packet = stream_dup (s);
   stream_free (s);
 
   /* Add packet to the peer. */
@@ -1056,7 +1040,7 @@
     }
 
   /* Make real packet. */
-  packet = bgp_packet_dup (s);
+  packet = stream_dup (s);
   stream_free (s);
 
   /* Add packet to the peer. */
@@ -1103,7 +1087,7 @@
   length = bgp_packet_set_size (s);
 
   /* Make real packet. */
-  packet = bgp_packet_dup (s);
+  packet = stream_dup (s);
   stream_free (s);
 
   /* Add packet to the peer. */
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 87e6b44..881a3c7 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -773,7 +773,7 @@
 
   /* Make peer's address string. */
   sockunion2str (su, buf, SU_ADDRSTRLEN);
-  peer->host = strdup (buf);
+  peer->host = XSTRDUP (MTYPE_BGP_PEER_HOST, buf);
 
   /* Set up peer's events and timers. */
   if (! active && peer_active (peer))
@@ -1136,7 +1136,7 @@
 
   /* Free allocated host character. */
   if (peer->host)
-    free (peer->host);
+    XFREE (MTYPE_BGP_PEER_HOST, peer->host);
 
   /* Local and remote addresses. */
   if (peer->su_local)
@@ -1146,7 +1146,7 @@
 
   /* Peer description string.  */
   if (peer->desc)
-    XFREE (MTYPE_TMP, peer->desc);
+    XFREE (MTYPE_PEER_DESC, peer->desc);
 
   bgp_sync_delete (peer);