On Wed, Feb 27, 2019 at 13:32:43 +0100, Michal Privoznik wrote: > On 2/27/19 10:52 AM, Erik Skultety wrote: > > On Tue, Feb 26, 2019 at 04:48:23PM +0100, Peter Krempa wrote: > > > Similar to VIR_AUTOPTR, VIR_AUTOSTRINGLIST defines a list of strings > > > which will be freed if the pointer is leaving scope. > > > > > > Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> > > > --- > > > src/libvirt_private.syms | 1 + > > > src/util/virstring.c | 10 ++++++++++ > > > src/util/virstring.h | 10 ++++++++++ > > > 3 files changed, 21 insertions(+) [...] > > > + */ > > > +# define VIR_AUTOSTRINGLIST \ > > > + __attribute__((cleanup(virStringListAutoFree))) char ** > > > + > > > > IIRC at the beginning we said that all the VIR_AUTO macros should be consistent > > in terms of how we use the macro, IOW: > > > > VIR_AUTOFREE(type) > > VIR_AUTOPTR(type) > > VIR_AUTOCLEAN(type) > > Well, we already have VIR_AUTOCLOSE. I don't mind having a macro that > implicitly defines type of a variable. It makes sense especially if the freeing function uses a specified type and thus you have to use it anyways. It actually prevents bugs. > On the other hand, this could be renamed to VIR_AUTOLISTFREE as it is > capable of freeing any NULL terminated list of pointers where plain free() > ove each member is enough. But it will have to lose the implicit type def in > that case. I proposed it in first version with a slightly more complex backed freeing function. It's quite useless with plain free() and I think it would invite to more bugs.
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list