X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fzone.c;h=87c65172292c6630a775a369be158bc9bf53e6f3;hb=1a0d2707d5fb73cd778831acf8af4980225b0bbc;hp=52dc55395bbd4edfc9d9eca1ad7ab636ffec15b7;hpb=43aca8ed8b22a7a5a14f8c740948d6ce06efbc95;p=collectd.git diff --git a/src/zone.c b/src/zone.c index 52dc5539..87c65172 100644 --- a/src/zone.c +++ b/src/zone.c @@ -34,8 +34,6 @@ #include "common.h" #include "plugin.h" -#include -#include #include #include @@ -49,20 +47,12 @@ typedef struct zone_stats { ushort_t pctmem; } zone_stats_t; -static long pagesize; - -static int zone_init (void) -{ - pagesize = sysconf(_SC_PAGESIZE); - return (0); -} - static int -zone_compare(const zoneid_t *a, const zoneid_t *b) +zone_compare(const void *a, const void *b) { - if (*a == *b) + if (*(const zoneid_t *)a == *(const zoneid_t *)b) return(0); - if (*a < *b) + if (*(const zoneid_t *)a < *(const zoneid_t *)b) return(-1); return(1); } @@ -121,6 +111,7 @@ zone_find_stats(c_avl_tree_t *tree, zoneid_t zoneid) } if (!(key = malloc(sizeof(*key)))) { WARNING("zone plugin: no memory"); + free(ret); return(NULL); } *key = zoneid; @@ -161,7 +152,7 @@ zone_scandir(DIR *procdir) c_avl_tree_t *tree; zone_stats_t *stats; - if (!(tree=c_avl_create((void *) zone_compare))) { + if (!(tree=c_avl_create(zone_compare))) { WARNING("zone plugin: Failed to create tree"); return(NULL); } @@ -209,6 +200,5 @@ static int zone_read (void) void module_register (void) { - plugin_register_init ("zone", zone_init); plugin_register_read ("zone", zone_read); } /* void module_register */