# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1257988817 28800
# Node ID e736e9f7808ee568704572c3e3f6c62ae26f3baf
# Parent 9e09e32ad29262203322b5ebac46d45198757a22
Add cleanup_virt_pool_res() for freeing virt_pool_res structs
Call cleanup_virt_pool_res() in Virt_ResourcePoolConfigurationService to
free allocated struct.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 9e09e32ad292 -r e736e9f7808e libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c Wed Nov 11 17:20:17 2009 -0800
+++ b/libxkutil/pool_parsing.c Wed Nov 11 17:20:17 2009 -0800
@@ -87,6 +87,29 @@
*pool = NULL;
}
+static void cleanup_image_res(struct storage_vol vol)
+{
+ free(vol.vol_name);
+ free(vol.path);
+ free(vol.cap_units);
+}
+
+void cleanup_virt_pool_res(struct virt_pool_res **res)
+{
+ struct virt_pool_res *_res = *res;
+
+ if ((res == NULL) || (*res == NULL))
+ return;
+
+ if (_res->type == CIM_RES_TYPE_IMAGE)
+ cleanup_image_res(_res->res.storage_vol);
+
+ free(_res->pool_id);
+ free(_res);
+
+ *res = NULL;
+}
+
static int parse_disk_target(xmlNode *node, struct disk_pool *pool)
{
xmlNode *child;
diff -r 9e09e32ad292 -r e736e9f7808e libxkutil/pool_parsing.h
--- a/libxkutil/pool_parsing.h Wed Nov 11 17:20:17 2009 -0800
+++ b/libxkutil/pool_parsing.h Wed Nov 11 17:20:17 2009 -0800
@@ -83,6 +83,7 @@
};
void cleanup_virt_pool(struct virt_pool **pool);
+void cleanup_virt_pool_res(struct virt_pool_res **res);
int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type);
diff -r 9e09e32ad292 -r e736e9f7808e src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c Wed Nov 11 17:20:17 2009 -0800
+++ b/src/Virt_ResourcePoolConfigurationService.c Wed Nov 11 17:20:17 2009 -0800
@@ -952,6 +952,8 @@
free(pool_id);
free(xml);
+ cleanup_virt_pool_res(&res);
+
if (s.rc == CMPI_RC_OK)
rc = CIM_SVPC_RETURN_COMPLETED;
CMReturnData(results, &rc, CMPI_uint32);