You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by John Hawkins <HA...@uk.ibm.com> on 2005/11/09 13:57:28 UTC

choice does not work?

Hi Folks,

In the reset() method of a choice type we do the following ->

/*do not allocate memory to any pointer members here
         because deserializer will allocate memory anyway. */
        memset( &a, 0, sizeof( xsd__string));
        memset( &b, 0, sizeof( xsd__int));
        memset( &c, 0, sizeof( xsd__dateTime));

Now, I see the commment but this doesn't work when the type is an input 
i.e. not created by the deserialiser the destructor does not work.

Can anyone tell me why we do this and not just ->
a=0;
b=0;
c=0; 

(which works for me)

thanks,
John.

Re: choice does not work?

Posted by Samisa Abeysinghe <sa...@gmail.com>.
John Hawkins wrote:

>
> Hi Folks,
>
> In the reset() method of a choice type we do the following ->
>
> /*do not allocate memory to any pointer members here
>          because deserializer will allocate memory anyway. */
>         memset( &a, 0, sizeof( xsd__string));
>         memset( &b, 0, sizeof( xsd__int));
>         memset( &c, 0, sizeof( xsd__dateTime));
>
> Now, I see the commment but this doesn't work when the type is an 
> input i.e. not created by the deserialiser the destructor does not work.
>
> Can anyone tell me why we do this and not just ->
> a=0;
> b=0;
> c=0;
>
> (which works for me)
>
I too am not sure whay memset was used here. I tried setting the members 
NULL as you have done some time back and seem to work. But did not 
change memset as I was not sure why it was used.

The original idea of using memset seem to come from 
http://issues.apache.org/jira/browse/AXISCPP-186

Thanks,
Samisa...

> thanks,
> John.