On Fri, 2018-05-25 at 10:46 +0200, Pavel Hrdina wrote:
> On Fri, May 25, 2018 at 10:32:04AM +0200, Andrea Bolognani wrote:
> > I'm probably missing something, but couldn't you just have
> > 
> >   #define VIR_AUTOFREE(type) __attribute__((cleanup(virFree))) type
> > 
> > which you would then use as
> > 
> >     VIR_AUTOFREE(char *) string = NULL;
> > 
> > instead?
> 
> Yes you can have that as well, but it doesn't look ugly to you? :)

Quite the opposite - not only it's consistent with the other
macros, but it also cleanly separates the type from the variable
name, which I consider a plus.

Personally, even though

  char *string;

and friends are the accepted way to declare pointer variables,
I've always been slightly annoyed by the fact that type name and
variable name end up being partially mixed together.

Don't get me wrong, something like

  char* string;

would still look wrong to me, because I'm just so used to the
other way! But in the context of that macro I think we really get
the best of both worlds :)

> If majority will agree on that I don't care, just my opinion.

Yeah, same here.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to