2005-01-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

	* buffer.h: Fix comment on buffer_getstr to reflect that it now
	  uses XMALLOC.
	* buffer.c: (buffer_getstr) Use XMALLOC(MTYPE_TMP) instead of malloc.
	* filter.c: (access_list_remark,ipv6_access_list_remark) Use
	  argv_concat instead of buffer_getstr.
	* if.c: (interface_desc) Use argv_concat instead of buffer_getstr.
	* plist.c: (ip_prefix_list_description,ipv6_prefix_list_description)
	  Use argv_concat instead of buffer_getstr.
	* bgp_filter.c: (ip_as_path,no_ip_as_path) Use argv_concat instead
	  of buffer_getstr.
	* bgp_route.c: (bgp_show_regexp) Fix memory leak: need to free string
	  returned by buffer_getstr.
	  (bgp_show_community) Must use XFREE instead of free on string
	  returned by buffer_getstr.
	* bgp_routemap.c: (set_community) Must use XFREE instead of free
	  on string returned by buffer_getstr.
	* bgp_vty.c: (neighbor_description) Use argv_concat instead of
	  buffer_getstr.
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 7955f09..34dad16 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,14 @@
+2005-01-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+	* buffer.h: Fix comment on buffer_getstr to reflect that it now
+	  uses XMALLOC.
+	* buffer.c: (buffer_getstr) Use XMALLOC(MTYPE_TMP) instead of malloc.
+	* filter.c: (access_list_remark,ipv6_access_list_remark) Use
+	  argv_concat instead of buffer_getstr.
+	* if.c: (interface_desc) Use argv_concat instead of buffer_getstr.
+	* plist.c: (ip_prefix_list_description,ipv6_prefix_list_description)
+	  Use argv_concat instead of buffer_getstr.
+
 2005-01-28 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
 	* lib/buffer.h: Document behavior of buffer_getstr function.
diff --git a/lib/buffer.c b/lib/buffer.c
index 60048bc..8666ab7 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -95,7 +95,7 @@
 
   for (data = b->head; data; data = data->next)
     totlen += data->cp - data->sp;
-  if (!(s = malloc(totlen+1)))
+  if (!(s = XMALLOC(MTYPE_TMP, totlen+1)))
     return NULL;
   p = s;
   for (data = b->head; data; data = data->next)
diff --git a/lib/buffer.h b/lib/buffer.h
index c3787d7..c0245a7 100644
--- a/lib/buffer.h
+++ b/lib/buffer.h
@@ -67,10 +67,9 @@
 void buffer_free (struct buffer *);
 
 /* Combine all accumulated (and unflushed) data inside the buffer into a
-   single NUL-terminated string allocated using malloc (N.B. should be changed
-   to use XMALLOC(MTYPE_TMP)).  Note that this function does not alter
-   the state of the buffer, so the data is still inside waiting to be
-   flushed. */
+   single NUL-terminated string allocated using XMALLOC(MTYPE_TMP).  Note
+   that this function does not alter the state of the buffer, so the data
+   is still inside waiting to be flushed. */
 char *buffer_getstr (struct buffer *);
 
 int buffer_putc (struct buffer *, u_char);
diff --git a/lib/filter.c b/lib/filter.c
index 9817c07..0dd7a77 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -1359,8 +1359,6 @@
        "Comment up to 100 characters\n")
 {
   struct access_list *access;
-  struct buffer *b;
-  int i;
 
   access = access_list_get (AFI_IP, argv[0]);
 
@@ -1369,19 +1367,7 @@
       XFREE (MTYPE_TMP, access->remark);
       access->remark = NULL;
     }
-
-  /* Below is remark get codes. */
-  b = buffer_new (1024);
-  for (i = 1; i < argc; i++)
-    {
-      buffer_putstr (b, argv[i]);
-      buffer_putc (b, ' ');
-    }
-  buffer_putc (b, '\0');
-
-  access->remark = buffer_getstr (b);
-
-  buffer_free (b);
+  access->remark = argv_concat(argv, argc, 1);
 
   return CMD_SUCCESS;
 }
@@ -1541,8 +1527,6 @@
        "Comment up to 100 characters\n")
 {
   struct access_list *access;
-  struct buffer *b;
-  int i;
 
   access = access_list_get (AFI_IP6, argv[0]);
 
@@ -1551,19 +1535,7 @@
       XFREE (MTYPE_TMP, access->remark);
       access->remark = NULL;
     }
-
-  /* Below is remark get codes. */
-  b = buffer_new (1024);
-  for (i = 1; i < argc; i++)
-    {
-      buffer_putstr (b, argv[i]);
-      buffer_putc (b, ' ');
-    }
-  buffer_putc (b, '\0');
-
-  access->remark = buffer_getstr (b);
-
-  buffer_free (b);
+  access->remark = argv_concat(argv, argc, 1);
 
   return CMD_SUCCESS;
 }
diff --git a/lib/if.c b/lib/if.c
index c7ced18..7385ff6 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -453,27 +453,15 @@
        "Interface specific description\n"
        "Characters describing this interface\n")
 {
-  int i;
   struct interface *ifp;
-  struct buffer *b;
 
   if (argc == 0)
     return CMD_SUCCESS;
 
   ifp = vty->index;
   if (ifp->desc)
-    XFREE (0, ifp->desc);
-
-  b = buffer_new (1024);
-  for (i = 0; i < argc; i++)
-    {
-      buffer_putstr (b, argv[i]);
-      buffer_putc (b, ' ');
-    }
-  buffer_putc (b, '\0');
-
-  ifp->desc = buffer_getstr (b);
-  buffer_free (b);
+    XFREE (MTYPE_TMP, ifp->desc);
+  ifp->desc = argv_concat(argv, argc, 0);
 
   return CMD_SUCCESS;
 }
diff --git a/lib/plist.c b/lib/plist.c
index 3520f82..5e2edd2 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -1561,8 +1561,6 @@
        "Up to 80 characters describing this prefix-list\n")
 {
   struct prefix_list *plist;
-  struct buffer *b;
-  int i;
 
   plist = prefix_list_get (AFI_IP, argv[0]);
   
@@ -1571,19 +1569,7 @@
       XFREE (MTYPE_TMP, plist->desc);
       plist->desc = NULL;
     }
-
-  /* Below is description get codes. */
-  b = buffer_new (1024);
-  for (i = 1; i < argc; i++)
-    {
-      buffer_putstr (b, argv[i]);
-      buffer_putc (b, ' ');
-    }
-  buffer_putc (b, '\0');
-
-  plist->desc = buffer_getstr (b);
-
-  buffer_free (b);
+  plist->desc = argv_concat(argv, argc, 1);
 
   return CMD_SUCCESS;
 }       
@@ -2171,8 +2157,6 @@
        "Up to 80 characters describing this prefix-list\n")
 {
   struct prefix_list *plist;
-  struct buffer *b;
-  int i;
 
   plist = prefix_list_get (AFI_IP6, argv[0]);
   
@@ -2181,19 +2165,7 @@
       XFREE (MTYPE_TMP, plist->desc);
       plist->desc = NULL;
     }
-
-  /* Below is description get codes. */
-  b = buffer_new (1024);
-  for (i = 1; i < argc; i++)
-    {
-      buffer_putstr (b, argv[i]);
-      buffer_putc (b, ' ');
-    }
-  buffer_putc (b, '\0');
-
-  plist->desc = buffer_getstr (b);
-
-  buffer_free (b);
+  plist->desc = argv_concat(argv, argc, 1);
 
   return CMD_SUCCESS;
 }