From: Sebastian Harl Date: Thu, 20 Mar 2008 10:03:32 +0000 (+0100) Subject: liboconfig/oconfig.c: Free all allocated memory in oconfig_free(). X-Git-Tag: collectd-4.2.6~13 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=12b23a0ff448672e04ffe2e0fb973751f8a42a34;p=collectd.git liboconfig/oconfig.c: Free all allocated memory in oconfig_free(). Signed-off-by: Sebastian Harl Signed-off-by: Florian Forster --- diff --git a/src/liboconfig/oconfig.c b/src/liboconfig/oconfig.c index 2bb80cc9..db9285b3 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); } /*