src/dp_rrdtool.c: Adapt to new callback prototype.
[collection4.git] / src / rrd_args.c
index f5358c8..f15d4cc 100644 (file)
@@ -1,3 +1,26 @@
+/**
+ * collection4 - rrd_args.c
+ * Copyright (C) 2010  Florian octo Forster
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Florian octo Forster <ff at octo.it>
+ **/
+
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -16,12 +39,14 @@ rrd_args_t *ra_create (void) /* {{{ */
   ra->options = array_create ();
   ra->data    = array_create ();
   ra->calc    = array_create ();
-  ra->draw    = array_create ();
+  ra->areas   = array_create ();
+  ra->lines   = array_create ();
 
   if ((ra->options == NULL)
       || (ra->data == NULL)
       || (ra->calc == NULL)
-      || (ra->draw == NULL))
+      || (ra->areas == NULL)
+      || (ra->lines == NULL))
   {
     ra_destroy (ra);
     return (NULL);
@@ -38,7 +63,8 @@ void ra_destroy (rrd_args_t *ra) /* {{{ */
   array_destroy (ra->options);
   array_destroy (ra->data);
   array_destroy (ra->calc);
-  array_destroy (ra->draw);
+  array_destroy (ra->areas);
+  array_destroy (ra->lines);
 
   free (ra);
 } /* }}} void ra_destroy */
@@ -51,7 +77,8 @@ int ra_argc (rrd_args_t *ra)
   return (array_argc (ra->options)
       + array_argc (ra->data)
       + array_argc (ra->calc)
-      + array_argc (ra->draw));
+      + array_argc (ra->areas)
+      + array_argc (ra->lines));
 } /* }}} int ra_argc */
 
 char **ra_argv (rrd_args_t *ra) /* {{{ */
@@ -75,6 +102,7 @@ char **ra_argv (rrd_args_t *ra) /* {{{ */
     return (NULL);
 
   pos = 0;
+  argv[0] = NULL;
 
 #define APPEND_FIELD(field) do                                               \
 {                                                                            \
@@ -89,17 +117,25 @@ char **ra_argv (rrd_args_t *ra) /* {{{ */
     pos += ary_argc;                                                         \
     argv[pos] = NULL;                                                        \
   }                                                                          \
-  free (ary_argv);                                                           \
 } while (0)
  
   APPEND_FIELD (options);
   APPEND_FIELD (data);
   APPEND_FIELD (calc);
-  APPEND_FIELD (draw);
+  APPEND_FIELD (areas);
+  APPEND_FIELD (lines);
 
 #undef APPEND_FIELD
 
   return (argv);
 } /* }}} char **ra_argv */
 
+void ra_argv_free (char **argv) /* {{{ */
+{
+  /* The pointers contained in the "argv" come from "array_argv". We don't need
+   * to free them. We only need to free what we actually alloced directly in
+   * "ra_argv". */
+  free (argv);
+} /* }}} void ra_argv_free */
+
 /* vim: set sw=2 sts=2 et fdm=marker : */