From: Florian Forster Date: Wed, 7 Jul 2010 13:54:01 +0000 (+0200) Subject: src/graph.[ch]: Implement "graph_sort_instances". X-Git-Tag: v4.0.0~133 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=f393a5cc0a2a7b0cd1d5b06166966d7af6f9daf5;p=collection4.git src/graph.[ch]: Implement "graph_sort_instances". --- diff --git a/src/graph.c b/src/graph.c index 49bd765..9d435c2 100644 --- a/src/graph.c +++ b/src/graph.c @@ -484,6 +484,20 @@ int graph_compare (graph_config_t *cfg, const graph_ident_t *ident) /* {{{ */ return (ident_compare (cfg->select, ident)); } /* }}} int graph_compare */ +int graph_sort_instances (graph_config_t *cfg) /* {{{ */ +{ + if (cfg == NULL) + return (EINVAL); + + if (cfg->instances_num < 2) + return (0); + + qsort (cfg->instances, cfg->instances_num, sizeof (*cfg->instances), + (void *) ident_compare); + + return (0); +} /* }}} int graph_sort_instances */ + int graph_clear_instances (graph_config_t *cfg) /* {{{ */ { size_t i; diff --git a/src/graph.h b/src/graph.h index 2be1a96..26b4ac6 100644 --- a/src/graph.h +++ b/src/graph.h @@ -85,6 +85,8 @@ int graph_inst_search_field (graph_config_t *cfg, int graph_compare (graph_config_t *cfg, const graph_ident_t *ident); +int graph_sort_instances (graph_config_t *cfg); + int graph_clear_instances (graph_config_t *cfg); int graph_get_rrdargs (graph_config_t *cfg, graph_instance_t *inst,