summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5a31f03)
raw | patch | inline | side by side (parent: 5a31f03)
author | Florian Forster <ff@octo.it> | |
Fri, 30 Apr 2010 15:54:26 +0000 (17:54 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 30 Apr 2010 15:54:26 +0000 (17:54 +0200) |
graph_list.c | patch | blob | history | |
graph_list.h | patch | blob | history |
diff --git a/graph_list.c b/graph_list.c
index baa8849ea0f9c9985e40da8457263f7e1404d0f8..1306335d3cdd9a84f69cc16efbfe17a25327cf45 100644 (file)
--- a/graph_list.c
+++ b/graph_list.c
#include "graph_list.h"
#include "common.h"
+#define UPDATE_INTERVAL 10
+
static graph_list_t *graph_list = NULL;
static size_t graph_list_length = 0;
static time_t gl_last_update = 0;
+static void gl_clear_entry (graph_list_t *gl) /* {{{ */
+{
+ if (gl == NULL)
+ return;
+
+ free (gl->host);
+ free (gl->plugin);
+ free (gl->plugin_instance);
+ free (gl->type);
+ free (gl->type_instance);
+
+ gl->host = NULL;
+ gl->plugin = NULL;
+ gl->plugin_instance = NULL;
+ gl->type = NULL;
+ gl->type_instance = NULL;
+} /* }}} void gl_clear_entry */
+
+static void gl_clear (void)
+{
+ size_t i;
+
+ for (i = 0; i < graph_list_length; i++)
+ gl_clear_entry (graph_list + i);
+
+ free (graph_list);
+ graph_list = NULL;
+ graph_list_length = 0;
+ gl_last_update = 0;
+} /* }}} void gl_clear */
+
static int gl_add_copy (graph_list_t *gl) /* {{{ */
{
graph_list_t *ptr;
now = time (NULL);
- if ((gl_last_update + 2) >= now)
+ if ((gl_last_update + UPDATE_INTERVAL) >= now)
return (0);
+ gl_clear ();
+
memset (&gl, 0, sizeof (gl));
gl.host = NULL;
gl.plugin = NULL;
diff --git a/graph_list.h b/graph_list.h
index 9fa1372738c551426b4f9d6d507dc61d66e5d51d..517b1b4c67252d507a646f4abcb0945ce208016f 100644 (file)
--- a/graph_list.h
+++ b/graph_list.h
int gl_update (void);
int gl_foreach (gl_callback callback, void *user_data);
-
#endif /* GRAPH_LIST_H */
/* vim: set sw=2 sts=2 et fdm=marker : */