[PATCH 1 of 3 RFC -V3] Header file for level 0 cmd server API
Laurens Holst
laurens.nospam at grauw.nl
Tue Aug 6 07:43:26 CDT 2013
Op 06-08-13 14:20, Iulian Stana schreef:
>
> > +
> > +/*
> > + * Close the connection for the given handle.
> > + * Erase the handle and free the memory
> > + * \param handle The handle of the connection that I want to close
> > + * \return 0 if successful
> > + * -1 to indicate an error, with errno set appropriately.
> > + * errno can be:
> > + * EINVAL
> > + * */
> > +int hg_close(hg_handle **handle);
>
> One '*' too many, unless you're planning on closing multiple
> handles at once...
>
>
> It's a defense action, I need to set the pointer to NULL, to be sure
> that there will
> be no other calls after hg_close. (We can assume that our users will
> not make
> this kind of action, then I will change to only one '*')
That does not help if the handle is also in another variable (e.g. of a
calling function).
I do think it's smart to defend against this, but it's better prevented
by always handing out unique handles that will cause an error if reused
after closing.
~Laurens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130806/0c4b2f27/attachment.html>
More information about the Mercurial-devel
mailing list