summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c9a8f04)
raw | patch | inline | side by side (parent: c9a8f04)
author | Florian Forster <ff@octo.it> | |
Wed, 21 Jul 2010 14:20:31 +0000 (16:20 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 21 Jul 2010 14:20:31 +0000 (16:20 +0200) |
src/graph.c | patch | blob | history | |
src/graph.h | patch | blob | history |
diff --git a/src/graph.c b/src/graph.c
index b654a1f30e26edb3f8fa4983c028f23c9095d3a7..ad47e46faed2ec173b1d59637a483581e58ed7c5 100644 (file)
--- a/src/graph.c
+++ b/src/graph.c
return (0);
} /* }}} graph_config_add */
+int graph_add_inst (graph_config_t *graph, graph_instance_t *inst) /* {{{ */
+{
+ graph_instance_t **tmp;
+
+ if ((graph == NULL) || (inst == NULL))
+ return (EINVAL);
+
+ tmp = realloc (graph->instances,
+ sizeof (*graph->instances) * (graph->instances_num + 1));
+ if (tmp == NULL)
+ return (ENOMEM);
+ graph->instances = tmp;
+
+ graph->instances[graph->instances_num] = inst;
+ graph->instances_num++;
+
+ return (0);
+} /* }}} int graph_add_inst */
+
int graph_add_file (graph_config_t *cfg, const graph_ident_t *file) /* {{{ */
{
graph_instance_t *inst;
inst = graph_inst_find_matching (cfg, file);
if (inst == NULL)
{
- graph_instance_t **tmp;
-
- tmp = realloc (cfg->instances,
- sizeof (*cfg->instances) * (cfg->instances_num + 1));
- if (tmp == NULL)
- return (ENOMEM);
- cfg->instances = tmp;
-
inst = inst_create (cfg, file);
if (inst == NULL)
return (ENOMEM);
- cfg->instances[cfg->instances_num] = inst;
- cfg->instances_num++;
+ graph_add_inst (cfg, inst);
}
return (inst_add_file (inst, file));
return (cfg->instances_num);
} /* }}} size_t graph_num_instances */
-int graph_to_json (const graph_config_t *cfg,
+int graph_to_json (const graph_config_t *cfg, /* {{{ */
yajl_gen handler)
{
size_t i;
yajl_gen_map_close (handler);
return (0);
-}
+} /* }}} int graph_to_json */
static int graph_sort_instances_cb (const void *v0, const void *v1) /* {{{ */
{
diff --git a/src/graph.h b/src/graph.h
index 0c4ff76b2e8ea14d3d0d94cc6b6371c0b8dcb044..e9c603ac8dcdbc2510bd42a7d16232627f5cdefe 100644 (file)
--- a/src/graph.h
+++ b/src/graph.h
int graph_config_add (const oconfig_item_t *ci);
+/* Add "inst" to the internal list. The instance is *not* copied and may not be
+ * freed from the outside. */
+int graph_add_inst (graph_config_t *graph, graph_instance_t *inst);
+
int graph_add_file (graph_config_t *cfg, const graph_ident_t *file);
int graph_get_title (graph_config_t *cfg,