[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



On Tue, 2014-05-20 at 15:54 +0100, Ian Jackson wrote:
> 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.

Yes.

> > 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.

Right, that is true, but the first call was destructive is what I was
getting at. I think I was simply thinking myself into circles.

> 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.

Right.

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®.