summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b2e0cf2)
raw | patch | inline | side by side (parent: b2e0cf2)
author | Florian Forster <octo@collectd.org> | |
Wed, 17 Jun 2015 06:35:22 +0000 (08:35 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 17 Jun 2015 06:35:47 +0000 (08:35 +0200) |
src/barometer.c | patch | blob | history |
diff --git a/src/barometer.c b/src/barometer.c
index 2bfd51e019d817487a8aefce7503c290ac54c59f..c1a7fa9474de61960d30a01ae6bc29e918b3ab70 100644 (file)
--- a/src/barometer.c
+++ b/src/barometer.c
*
* @return Zero when successful
*/
-static int averaging_create(averaging_t * avg, int size)
+static int averaging_create(averaging_t *avg, int size)
{
- int a;
-
- avg->ring_buffer = (long int *) malloc(size * sizeof(*avg));
+ avg->ring_buffer = calloc ((size_t) size, sizeof (*avg));
if (avg->ring_buffer == NULL)
{
ERROR ("barometer: averaging_create - ring buffer allocation of size %d failed",
return -1;
}
- for (a=0; a<size; ++a)
- {
- avg->ring_buffer[a] = 0L;
- }
-
avg->ring_buffer_size = size;
avg->ring_buffer_sum = 0L;
avg->ring_buffer_head = 0;