[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[libvirt] [PATCH] fix memory leak in __virStringListFree
- From: David Lively <dlively virtualiron com>
- To: libvir-list <libvir-list redhat com>
- Subject: [libvirt] [PATCH] fix memory leak in __virStringListFree
- Date: Fri, 24 Oct 2008 15:03:58 -0400
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;
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]