You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Subra Aswathanarayanan <as...@gmail.com> on 2008/12/23 01:03:18 UTC

freeing up memory after sending response

Hello,

I have a webservice in which I allocate memory for a variable and then use
that variable in creating a soap response like this

        objType_om_ele = axiom_element_create(env, response_node,
OBJECT_TYPE, ns, &objType_om_node);
        axiom_element_set_text(objType_om_ele, env, objectType,
objType_om_node);


here the variable "objectType" was malloc'd using AXIS2_MALLOC function.

in the end i return response_node and the client receives the soap response.

my question is, when should i free the memory that i allocated. i dont think
i can free it before i return "response_node" and i cant free it after the
return statement either.

your help is much appreciated!

Subra

Re: freeing up memory after sending response

Posted by Uthaiyashankar <sh...@wso2.com>.
Hi Subra,

Hello,
>
> I have a webservice in which I allocate memory for a variable and then use
> that variable in creating a soap response like this
>
>         objType_om_ele = axiom_element_create(env, response_node,
> OBJECT_TYPE, ns, &objType_om_node);
>         axiom_element_set_text(objType_om_ele, env, objectType,
> objType_om_node);
>
>
> here the variable "objectType" was malloc'd using AXIS2_MALLOC function.
>
> in the end i return response_node and the client receives the soap
> response.
>
> my question is, when should i free the memory that i allocated.


Are you talking about freeing "objectType"? If that's the case, you can free
it just after setting "axiom_element_set_text" (before returning
"response_node").

Regards,
Shankar


-- 
S.Uthaiyashankar
Software Architect
WSO2 Inc.
http://wso2.com/ - "The Open Source SOA Company"