X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fconfigfile.c;h=ec39b76034fa21c8d8a9f4c066f0419d6f0bcb79;hb=587f01f89af11c4acebbec44293528b77c779218;hp=88bed1c436a4d9fa89a4bfefaffacd3b386cfb5a;hpb=1115921a0d8f73c08fd505344af4266105e1155d;p=collectd.git diff --git a/src/configfile.c b/src/configfile.c index 88bed1c4..ec39b760 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -109,8 +109,8 @@ static cf_global_option_t cf_global_options[] = {"Interval", NULL, NULL}, {"ReadThreads", NULL, "5"}, {"WriteThreads", NULL, "5"}, - {"WriteQueueLengthLimitHigh", NULL, NULL}, - {"WriteQueueLengthLimitLow", NULL, NULL}, + {"WriteQueueLimitHigh", NULL, NULL}, + {"WriteQueueLimitLow", NULL, NULL}, {"Timeout", NULL, "2"}, {"AutoLoadPlugin", NULL, "false"}, {"PreCacheChain", NULL, "PreCache"}, @@ -477,6 +477,12 @@ static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src, /* Resize the memory containing the children to be big enough to hold * all children. */ + if (dst->children_num + src->children_num - 1 == 0) + { + dst->children_num = 0; + return (0); + } + temp = (oconfig_item_t *) realloc (dst->children, sizeof (oconfig_item_t) * (dst->children_num + src->children_num - 1)); @@ -591,7 +597,8 @@ static int cf_include_all (oconfig_item_t *root, int depth) return (-1); /* Now replace the i'th child in `root' with `new'. */ - cf_ci_replace_child (root, new, i); + if (cf_ci_replace_child (root, new, i) < 0) + return (-1); /* ... and go back to the new i'th child. */ --i; @@ -917,6 +924,23 @@ const char *global_option_get (const char *option) : cf_global_options[i].def); } /* char *global_option_get */ +long global_option_get_long (const char *option, long default_value) +{ + const char *str; + long value; + + str = global_option_get (option); + if (NULL == str) + return (default_value); + + errno = 0; + value = strtol (str, /* endptr = */ NULL, /* base = */ 0); + if (errno != 0) + return (default_value); + + return (value); +} /* char *global_option_get_long */ + cdtime_t cf_get_default_interval (void) { char const *str = global_option_get ("Interval");