On 8/15/19 5:22 AM, Richard W.M. Jones wrote:
On Wed, Aug 14, 2019 at 05:38:31PM -0500, Eric Blake wrote:
> When we introduced valid_flags, there was an incentive to do as few
> callbacks as possible, favoring cb(VALID|FREE) calls over the sequence
> cb(VALID);cb(FREE). To make it work, we set .callback=NULL after an
> early free, so that the later check during retirement didn't free
> again.
>
> But now that our .free callback is distinct from our other callbacks,
> there is no longer an advantage to bundling things, and a significant
> reduction in lines of code by just doing it in one place. This
> basically reverts 9c8fccdf (which had slightly-questionable C
> type-punning anyway) and 57150880.
I didn't see this one before implementing an alternate version here:
https://www.redhat.com/archives/libguestfs/2019-August/msg00251.html
https://www.redhat.com/archives/libguestfs/2019-August/msg00253.html
They're fairly similar, but I didn't get rid of the FREE_CALLBACK
macro for reasons which are clearer later in the series.
Yeah, having looked at yours, you got rid of the type-punning but added
more convenience macros instead of dropping them; I'm fine with yours.
Good to know we were thinking on the same lines :)
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org