[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH V5 07/32] libxl.h: document the paradigm of using libxl types



Ian Campbell writes ("Re: [PATCH V5 07/32] libxl.h: document the paradigm of 
using libxl types"):
> On Tue, 2014-05-13 at 22:53 +0100, Wei Liu wrote:
> > + * once afterwards, to clean up, regardless of whether operations on
> > + * this object succeeded or failed.  See the xl code for examples.
> > + *
> > + * "init" is idempotent.
> 
> I wondered if this was true, or if calling it twice would leak. None of
> the _init functions allocate any memory so this is OK, I think.

I think it's a necessary guarantee that they don't, for this to be a
convenient interface.

> Calling init on a partially setup object could leak things though, so
> init is only idempotent until you initialise some of the fields, which
> isn't a terribly useful guarantee I don't think.

Uh.  What a strange thing to say.

init is idempotent even if you have already filled in some of the
fields with allocated values.  If you initialise some of the fields
and then call init one or more times it's just like calling it once.

What you mean is that it is _incorrect_ to call init on a struct with
allocations in it.  Yes.  That's surely obvious.  But it has nothing
to do with idempotency.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.