Created attachment 5646 Fix memory leak Hello, the patch sent by me has a memory leak bug. I am sending a patch to fix this.
Using globals is a bit awkward here.. i'm sure there's a better way. Also, to which patch you sent previously are you reffering to ?
Created attachment 5647 New patch
I sent the patch one year ago [1] I'm sending a better patch, sorry my fast solution haha :P http://git.xfce.org/panel-plugins/xfce4-diskperf-plugin/commit/?id=0faba9adc585a02071b4ab1d8761413b4cc35a9a
I've looked at the code, and i dont see where there's a leak in the code you want to change, given that we only use local variables/structures, and none seem malloc'ed at each call.. care to explain a bit more ?
The function devstat_getdevs allocates a structure devinfo when stats.dinfo is NULL. This should be done just once. In my code I'm using memset to fill both structures with zeros on every call of DevGetPerfData. Thus, devstat_getdevs is allocating a new devinfo every time, but never freeing it. Passing a valid pointer to stats.dinfo avoids the malloc inside devstat_getdevs.
Ok, makes sense now - pushed in 5c81437
Thanks! :)