axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From susan...@opensource.lk
Subject Re: returning array of string from service
Date Thu, 03 Jun 2004 06:04:08 GMT
Hi,

> i have a simple service implemented in Axis-C++ that take as input array
> length and returns new arrray of strings.
>
> is it the right way to do it so there is no memory leaks (i looked on
> InteropBaseClient.cpp ti see how string arrays are created).
>
> xsd__string_Array Benchmark1PortType::sendStrings(int length)
> {
>    xsd__string_Array arr;
>    arr.m_Size = length;
>    arr.m_Array = new char*[length];
>    for (int i=0; i < length; i++) {
>        arr.m_Array[i] = strdup("hello str::Alek");
>    }
>    return arr;
> }

Yes. This returned array will be de-allocated after serialization. So no
memory leaks.

>
> i would like to see how server side AXIS-C++ works in longer run
> (especially memory handling) so i would like to get this right ...
>
> thanks,
>
> alek
>
> BTW: maybe it would be good idea to have consistent naming for example
> xsd__base64Binary::__size and xsd__string_Array::m_Size - shouldnt both
> use m_Size? that makes this method asymmetrical to all other methods
> handling arrays:

xsd__xxxx are Axis defined types
and
xsd__xxxx_Array are Axis defined array structures.

>
> xsd__base64Binary Benchmark1PortType::sendBase64(int length)
> {
>     xsd__base64Binary arr;
>     arr.__size = length;
>     arr.__ptr = new xsd__unsignedByte[length];
>     for (int i=0; i < length; i++) {
>         arr.__ptr[i] = (xsd__unsignedByte)i;
>     }
>     return arr;
> }
>
> --
> The best way to predict the future is to invent it - Alan Kay
>
>
>


Mime
View raw message