Merge branch 'collectd-4.2' into collectd-4.3
[collectd.git] / src / liboconfig / oconfig.c
index f8d1849..db9285b 100644 (file)
 
 #include "oconfig.h"
 
-/* Functions provided by the scanner */
-void yyset_in  (FILE *);
+extern FILE *yyin;
 
 oconfig_item_t *ci_root;
 
+static void yyset_in  (FILE *fd)
+{
+  yyin = fd;
+} /* void yyset_in */
+
 oconfig_item_t *oconfig_parse_fh (FILE *fh)
 {
   int status;
@@ -72,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);
 }
 
 /*