From: Florian Forster Date: Mon, 18 Feb 2008 19:41:38 +0000 (+0100) Subject: rrdtool plugin: Sort the list of user defined `RRATimespan's. X-Git-Tag: collectd-4.3.0~8^2^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=8461fc51ea1af63b4d51c106d128716ecf95bf10;p=collectd.git rrdtool plugin: Sort the list of user defined `RRATimespan's. This is required by the logic calculating the RRA sized. --- diff --git a/src/rrdtool.c b/src/rrdtool.c index 79331bf7..843aa2bf 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -891,6 +891,19 @@ static int rrd_cache_insert (const char *filename, return (0); } /* int rrd_cache_insert */ +static int rrd_compare_numeric (const void *a_ptr, const void *b_ptr) +{ + int a = *((int *) a_ptr); + int b = *((int *) b_ptr); + + if (a < b) + return (-1); + else if (a > b) + return (1); + else + return (0); +} /* int rrd_compare_numeric */ + static int rrd_write (const data_set_t *ds, const value_list_t *vl) { struct stat statbuf; @@ -1029,6 +1042,12 @@ static int rrd_config (const char *key, const char *value) if (rra_timespans_custom[rra_timespans_custom_num] != 0) rra_timespans_custom_num++; } /* while (strtok_r) */ + + qsort (/* base = */ rra_timespans_custom, + /* nmemb = */ rra_timespans_custom_num, + /* size = */ sizeof (rra_timespans_custom[0]), + /* compar = */ rrd_compare_numeric); + free (value_copy); } else if (strcasecmp ("XFF", key) == 0)