Re: [libvirt] [PATCH] fix memory leak in __virStringListFree

2008-10-29 Thread Daniel Veillard
On Fri, Oct 24, 2008 at 03:03:58PM -0400, David Lively wrote:
 Currently __virStringListFree is freeing only the list nodes, but not
 the strings on the list (and neither is anyone else freeing these).
 This small patch fixes that, and documents the two __virStringList
 functions.

Well, Dan Berrange cleanup patch suggests to just get rid of the
functions, maybe that's an even nicer approach :-)

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
[EMAIL PROTECTED]  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] fix memory leak in __virStringListFree

2008-10-24 Thread David Lively
Currently __virStringListFree is freeing only the list nodes, but not
the strings on the list (and neither is anyone else freeing these).
This small patch fixes that, and documents the two __virStringList
functions.

Dave

diff --git a/src/libvirt.c b/src/libvirt.c
index 8fd594b..bee98d2 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -5308,8 +5308,18 @@ virStorageVolGetPath(virStorageVolPtr vol)
 
 
 
-/* Not for public use.  Combines the elements of a virStringList
+/**
+ * __virStringListJoin:
+ * @list: the StringList
+ * @pre: string to prepend to the result string
+ * @post: string to append to the result string
+ * @sep: string to separate the list elements
+ *
+ * Internal function to combine the elements of a virStringList
  * into a single string.
+ *
+ * Returns the resulting string, which the caller is responsible
+ * for freeing when they're done with it.  Returns NULL on error.
  */
 char *__virStringListJoin(const virStringList *list, const char *pre,
 const char *post, const char *sep)
@@ -5338,10 +5348,17 @@ char *__virStringListJoin(const virStringList *list, const char *pre,
 }
 
 
+/**
+ * __virStringListFree:
+ * @list: the StringList to free
+ *
+ * Internal function to free the memory used by a string list.
+ */
 void __virStringListFree(virStringList *list)
 {
 while (list) {
 virStringList *p = list-next;
+VIR_FREE(list-val);
 VIR_FREE(list);
 list = p;
 }
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list