[collectd] [PATCH] liboconfig/oconfig.c: Free all allocated memory in oconfig_free().
Sebastian Harl
sh at tokkee.org
Thu Mar 20 11:03:32 CET 2008
Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
After adopting the pathname of oconfig.c, this patch should apply to
liboping as well.
---
src/liboconfig/oconfig.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/liboconfig/oconfig.c b/src/liboconfig/oconfig.c
index 2bb80cc..db9285b 100644
--- a/src/liboconfig/oconfig.c
+++ b/src/liboconfig/oconfig.c
@@ -76,11 +76,25 @@ void oconfig_free (oconfig_item_t *ci)
{
int i;
+ if (ci == NULL)
+ return;
+
+ if (ci->key != NULL)
+ free (ci->key);
+
+ for (i = 0; i < ci->values_num; i++)
+ if ((ci->values[i].type == OCONFIG_TYPE_STRING)
+ && (NULL != ci->values[i].value.string))
+ free (ci->values[i].value.string);
+
if (ci->values != NULL)
free (ci->values);
for (i = 0; i < ci->children_num; i++)
oconfig_free (ci->children + i);
+
+ if (ci->children != NULL)
+ free (ci->children);
}
/*
--
1.5.4.3.325.g6d216
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080320/2fb38df5/attachment-0001.pgp
More information about the collectd
mailing list