axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aleksander Slominski <as...@cs.indiana.edu>
Subject Re: memory management and AXIS_DEFINED_ARRAY
Date Fri, 28 May 2004 23:30:19 GMT
followup: it seems that skeleton is just calling

    pIWSSZ->addOutputBasicArrayParam((Axis_Array*)(&ret),XSD_INT, 
"echoIntsReturn");

after looking it in source code it seems thta is acutally called isL

SoapSerializer::addOutputBasicArrayParam(const Axis_Array* pArray,
                                             XSDTYPE nType,
                                             const AxisChar* pName)

which as far as i can tell does not deallocate pArray?

is it memory leak for sendInts?

if i have 3 methods like this what is the right way to manage memory (by 
caller)?

        xsd__int_Array echoInts(xsd__int_Array Value0);
        int receiveInts(xsd__int_Array Value0);
        xsd__int_Array sendInts(int Value0);

thanks,

alek


int Benchmark1PortTypeWrapper::sendInts(void* pMsg)
{
    IMessageData* mc = (IMessageData*)pMsg;
    int nStatus;
    IWrapperSoapSerializer *pIWSSZ = NULL;
    mc->getSoapSerializer(&pIWSSZ);
    if (!pIWSSZ) return AXIS_FAIL;
    IWrapperSoapDeSerializer *pIWSDZ = NULL;
    mc->getSoapDeSerializer(&pIWSDZ);
    if (!pIWSDZ) return AXIS_FAIL;
    /* check whether we have got correct message */
    if (AXIS_SUCCESS != pIWSDZ->checkMessageBody("sendInts", 
"http://www.extreme.indiana.edu/wsdl/Benchmark1.wsdl")) return AXIS_FAIL;
    pIWSSZ->createSoapMethod("sendIntsResponse", 
"http://www.extreme.indiana.edu/wsdl/Benchmark1.wsdl");
    int v0 = pIWSDZ->getElementAsInt("size",0);
    if (AXIS_SUCCESS != (nStatus = pIWSDZ->getStatus())) return nStatus;
    xsd__int_Array ret = pWs->sendInts(v0);
    return pIWSSZ->addOutputBasicArrayParam((Axis_Array*)(&ret),XSD_INT, 
"sendIntsReturn");
}


int SoapSerializer::addOutputBasicArrayParam(const Axis_Array* pArray,
                                             XSDTYPE nType,
                                             const AxisChar* pName)
{
    IArrayBean* pAb = makeArrayBean(nType, (void*)(pArray->m_Array));
    pAb->SetDimension(pArray->m_Size);
    Param* pParam = new Param();
    if (RPC_ENCODED == m_nStyle)
    {
        pAb->SetItemName("item");
        pParam->setName(pName);
    }
    else
    {
        pAb->SetItemName(pName);
        pParam->setName("array");       
    }
    pParam->m_Value.pIArray = pAb;
    pParam->m_Type = XSD_ARRAY;
    if(m_pSoapEnvelope && (m_pSoapEnvelope->m_pSoapBody) &&
        (m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
    {
        m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod->addOutputParam(pParam);
    }
    return AXIS_SUCCESS;
}


IArrayBean* SoapSerializer::makeArrayBean(XSDTYPE nType, void* pArray)
{
    ArrayBean* pAb = new ArrayBean();
    pAb->m_type = nType;
    pAb->m_value.sta = pArray;
    return pAb;
}
Aleksander Slominski wrote:

> hi,
>
> how is it supposed to be used - if i return new allocated 
> AXIS_DEFINED_ARRAY will it be automatically deallocated?!
>
> for example is this valid way to do echo? i have seen it in 
> InteropTestPortType.cpp so that should be fine though in this case i 
> do not understand who is de-allocating memory as xsd__int_Array is 
> passed as input and returned as output? shouldnt service clone the 
> array or auto pointer be used?
>
> xsd__int_Array Benchmark1PortType::echoInts(xsd__int_Array Value0)
> {
>    return Value0;
> }
>
> and what about returning new value?
>
> xsd__int_Array Benchmark1PortType::sendInts(int length)
> {
>    xsd__int_Array arr;
>    arr.m_Size = length;
>    arr.m_Array = (int *) malloc(length * sizeof(int));
>    // fill in array with values
>    return arr;
> }
>
> will it be de-allocated? do i miss something (documentation, examples)?
>
> thanks,
>
> alek
>


-- 
The best way to predict the future is to invent it - Alan Kay


Mime
View raw message