Code

timeseries: Added sdb_timeseries_destroy().
authorSebastian Harl <sh@tokkee.org>
Sat, 16 Aug 2014 17:10:06 +0000 (19:10 +0200)
committerSebastian Harl <sh@tokkee.org>
Sat, 16 Aug 2014 17:10:06 +0000 (19:10 +0200)
src/Makefile.am
src/core/timeseries.c [new file with mode: 0644]
src/include/core/timeseries.h

index c7c53e3289189d9fbb7a67ba4cd7151b18ba1758..faea551fb3522a2a4a2c74b840d04a108b1e18fe 100644 (file)
@@ -74,7 +74,7 @@ libsysdb_la_SOURCES = \
                core/store_expr.c \
                core/store_lookup.c \
                core/data.c include/core/data.h \
-               include/core/timeseries.h \
+               core/timeseries.c include/core/timeseries.h \
                frontend/connection.c include/frontend/connection.h \
                frontend/connection-private.h \
                frontend/parser.c include/frontend/parser.h \
diff --git a/src/core/timeseries.c b/src/core/timeseries.c
new file mode 100644 (file)
index 0000000..48da7f8
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * SysDB - src/core/timeseries.c
+ * Copyright (C) 2014 Sebastian 'tokkee' Harl <sh@tokkee.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "sysdb.h"
+#include "core/timeseries.h"
+
+#include <stdlib.h>
+
+/*
+ * public API
+ */
+
+void
+sdb_timeseries_destroy(sdb_timeseries_t *ts)
+{
+       size_t i;
+
+       if (! ts)
+               return;
+
+       if (ts->data)
+               free(ts->data);
+       ts->data = NULL;
+       ts->data_len = 0;
+
+       for (i = 0; i < ts->data_names_len; ++i) {
+               if (ts->data_names[i])
+                       free(ts->data_names[i]);
+               ts->data_names[i] = NULL;
+       }
+       if (ts->data_names)
+               free(ts->data_names);
+       ts->data_names = NULL;
+       ts->data_names_len = 0;
+} /* sdb_timeseries_destroy */
+
+/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
+
index 3a4029d8be4b2d46e8365d3904e9fcbfe1706a9f..52848a71d948954f3a9bceebe970f2520f6d68c9 100644 (file)
@@ -69,6 +69,13 @@ typedef struct {
        sdb_time_t end;
 } sdb_timeseries_opts_t;
 
+/*
+ * sdb_timeseries_destroy:
+ * Destroy a time-series object, freeing all of its memory.
+ */
+void
+sdb_timeseries_destroy(sdb_timeseries_t *ts);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif