summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 914cf84)
raw | patch | inline | side by side (parent: 914cf84)
author | Manuel Luis SanmartĂn Rozada <manuel.luis@gmail.com> | |
Wed, 20 May 2015 18:52:58 +0000 (20:52 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 31 May 2015 20:42:30 +0000 (22:42 +0200) |
Collect option but the code expecs t"Collect n1 n2 n3 n4", fix
to allow to put the option Collect multiple times.
to allow to put the option Collect multiple times.
src/tail_csv.c | patch | blob | history |
diff --git a/src/tail_csv.c b/src/tail_csv.c
index 6c3d5f73f69ed788a502f928bb70f4cabcf67826..4794f82eb542fb4c69392e3b53e1c37426c8cc2d 100644 (file)
--- a/src/tail_csv.c
+++ b/src/tail_csv.c
static int tcsv_config_add_instance_collect(instance_definition_t *id, oconfig_item_t *ci){
metric_definition_t *metric;
- int i;
+ metric_definition_t **metric_list;
+ int i,j,n;
if (ci->values_num < 1){
WARNING("tail_csv plugin: The `Collect' config option needs at least one argument.");
@@ -393,17 +394,20 @@ static int tcsv_config_add_instance_collect(instance_definition_t *id, oconfig_i
return (-1);
}
- id->metric_list = (metric_definition_t **)malloc(sizeof(metric_definition_t *) * ci->values_num);
- if (id->metric_list == NULL)
+ n = id->metric_list_len + ci->values_num;
+ metric_list = (metric_definition_t **)realloc(id->metric_list, sizeof(metric_definition_t *) * n);
+ if (metric_list == NULL)
return (-1);
- for (i = 0; i < ci->values_num; ++i){
+ id->metric_list = metric_list;
+
+ for (i = id->metric_list_len, j=0; i < n; ++i, ++j){
for (metric = metric_head; metric != NULL; metric = metric->next)
- if (strcasecmp(ci->values[i].value.string, metric->name) == 0)
+ if (strcasecmp(ci->values[j].value.string, metric->name) == 0)
break;
if (metric == NULL){
- WARNING("tail_csv plugin: `Collect' argument not found `%s'.", ci->values[i].value.string);
+ WARNING("tail_csv plugin: `Collect' argument not found `%s'.", ci->values[j].value.string);
return (-1);
}