[PATCH 9/9] util: Avoid using wrong free function

Peter Krempa pkrempa at redhat.com
Tue Jun 16 12:14:46 UTC 2020


On Tue, Jun 16, 2020 at 08:07:10 -0400, John Ferlan wrote:
> Since 1e2ae2e31, changes to use the automagic free logic didn't take
> into account that one path uses posix_memalign and the other uses
> VIR_ALLOC_N - the former requires using VIR_FREE() and not g_free()
> to free the memory.

I don't really think this makes sense. VIR_FREE is now using
g_clear_pointer(&PTR, g_free) internally, so g_free will be used
regardless.

Is the problem really in g_free or rather some kind of problem with the
__attribute__(cleanup)) feature?

Additionally this fix looks weird. I'd prefer if autofree is dropped
here and VIR_FREE is used directly in both cases if this in fact fixes
the problem as there is no reason to keep g_autofree just in one case.




More information about the libvir-list mailing list