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.
This commit is contained in:
Dominik Honnef 2016-12-31 07:23:55 +01:00
commit 38c5890428
3 changed files with 12 additions and 5 deletions

View file

@ -10,10 +10,9 @@
#include <devstat_freebsd.h>
int _get_stats(Stats **stats) {
int _get_stats(struct devinfo *info, Stats **stats) {
struct statinfo current;
struct devinfo info = {};
current.dinfo = &info;
current.dinfo = info;
if (devstat_getdevs(NULL, &current) == -1) {
return -1;