summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e481a79)
raw | patch | inline | side by side (parent: e481a79)
author | Florian Forster <octo@verplant.org> | |
Wed, 8 Sep 2010 15:19:45 +0000 (17:19 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Wed, 8 Sep 2010 15:19:45 +0000 (17:19 +0200) |
src/dp_rrdtool.c | patch | blob | history |
diff --git a/src/dp_rrdtool.c b/src/dp_rrdtool.c
index 6db02059d6a95ebfe87fd17b2a0b98e5bd6f8eeb..f90b79e913a979194117c81078492ab8b54c7cce 100644 (file)
--- a/src/dp_rrdtool.c
+++ b/src/dp_rrdtool.c
unsigned long data_index;
unsigned long data_length;
+ dp_data_point_t *dp = NULL;
+ size_t dp_num = 0;
+
status = ident_to_rrdfile (ident, config, filename, sizeof (filename));
if (status != 0)
return (status);
free (ds_namv[i]); \
free (ds_namv); \
free (data); \
+ free (dp); \
return (ret_status); \
} while (0)
/* Number of data points returned. */
data_length = (rrd_end - rrd_start) / step;
+ dp_num = (size_t) data_length;
+ dp = calloc (dp_num, sizeof (*dp));
+ if (dp == NULL)
+ BAIL_OUT (ENOMEM);
+
for (data_index = 0; data_index < data_length; data_index++)
{
- dp_data_point_t dp;
unsigned long index = (ds_count * data_index) + ds_index;
- memset (&dp, 0, sizeof (dp));
- dp.time.tv_sec = rrd_start + (data_index * step);
- dp.time.tv_nsec = 0;
- dp.value = (double) data[index];
-
- status = (*cb) (ident, ds_name, &dp, ud);
- if (status != 0)
- BAIL_OUT (status);
+ dp[data_index].time.tv_sec = rrd_start + (data_index * step);
+ dp[data_index].time.tv_nsec = 0;
+ dp[data_index].value = (double) data[index];
}
+ status = (*cb) (ident, ds_name, dp, dp_num, ud);
+ if (status != 0)
+ BAIL_OUT (status);
+
BAIL_OUT (0);
#undef BAIL_OUT
} /* }}} int get_ident_data */