[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: multi-valued returns in SWIG (was: Rcsparse.py)

From: Marshall White <cscidork_at_yahoo.com>
Date: 2003-03-01 21:43:47 CET

--- Greg Stein <gstein@lyra.org> wrote:
> On Fri, Feb 28, 2003 at 09:14:15PM -0800, Marshall White wrote:
> >...
> > BTW: This one other piece is really important:
> >
> > Log:
> > * subversion/bindings/swig/svn_string.i
> > Initialize the temp variable to NULL for the SWIG binding
> > %typemap(in, numinputs=0) const char **OUTPUT
>
> Why is this important? What is the problem that it is trying to solve?
>
> I know that our functions are not expecting the temp var to be NULL. IOW,
> whenever we have a 'const char **foo' function, where foo is a return value,
> then the function typically doesn't care what the input value is. Does one
> of the SVN functions actually require the initialization?

It wasn't the Subversion function that expects it to be NULL, it is the SWIG function.
The generated code goes roughly like this:

char *temp;
char **temp_ptr = &temp;
subversion_func(temp_ptr);
if (temp == NULL)

If the variable "temp" is not initialized to NULL and the Subversion function doesn't explicitly
set it to NULL, who knows what will happen.
Although I haven't seen Subversion do it YET, my test code seg faults without the initialization.
If you can guarantee that the Subversion functions will always set it to NULL, then it is not such
a big deal.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Mar 1 21:44:30 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.