diff options
author | Dominik Honnef <dominik@honnef.co> | 2016-12-31 07:23:55 +0100 |
---|---|---|
committer | Dominik Honnef <dominik@honnef.co> | 2017-01-05 05:38:26 +0100 |
commit | 38c589042815e09ce3bda631f3e244f952ed1721 (patch) | |
tree | e8a2aeeb5f8a3cb50313d319e40bf1fdf4cd9753 /collector/devstat_freebsd.c | |
parent | ea55d0f5cb8062f311891c20f2d5d11c62241cf8 (diff) | |
download | prometheus_node_collector-38c589042815e09ce3bda631f3e244f952ed1721.tar.bz2 prometheus_node_collector-38c589042815e09ce3bda631f3e244f952ed1721.tar.xz prometheus_node_collector-38c589042815e09ce3bda631f3e244f952ed1721.zip |
Reuse devinfo struct
The devstat API expects us to reuse one devinfo for many invocations of
devstat_getstats. In particular, it allocates and resizes memory
referenced by devinfo.
Diffstat (limited to 'collector/devstat_freebsd.c')
-rw-r--r-- | collector/devstat_freebsd.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/collector/devstat_freebsd.c b/collector/devstat_freebsd.c index 80a24e4..c3352e2 100644 --- a/collector/devstat_freebsd.c +++ b/collector/devstat_freebsd.c | |||
@@ -10,10 +10,9 @@ | |||
10 | #include <devstat_freebsd.h> | 10 | #include <devstat_freebsd.h> |
11 | 11 | ||
12 | 12 | ||
13 | int _get_stats(Stats **stats) { | 13 | int _get_stats(struct devinfo *info, Stats **stats) { |
14 | struct statinfo current; | 14 | struct statinfo current; |
15 | struct devinfo info = {}; | 15 | current.dinfo = info; |
16 | current.dinfo = &info; | ||
17 | 16 | ||
18 | if (devstat_getdevs(NULL, ¤t) == -1) { | 17 | if (devstat_getdevs(NULL, ¤t) == -1) { |
19 | return -1; | 18 | return -1; |