X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Frrdtool.c;h=024b04e5e928a11daaeb6edb31d0a985a8c1af4d;hb=89783745dc59079eab34e0c52de6e5e972f50eb2;hp=dc06d68a100eac4013b6080d9027df154345135a;hpb=c89c9b7b5e498e5a77c6eb1b1a88593fcced85f5;p=collectd.git diff --git a/src/rrdtool.c b/src/rrdtool.c index dc06d68a..024b04e5 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -893,6 +893,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; @@ -1031,6 +1044,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)