I am writing a web server and client test stub for it. I have questions regarding memory management of the parameters.
From my client I am calling a soap function ns1_func1(input * pInput, output* pOutput) Now both input and output class contain pointers to other structs.
For e.g
class Output { class abc * p1; class def * p2; };
My question is - who is responsible for memory allocations? Is client responsible for input memory allocations and server responsible for output memory management?
Right now my client code looks somthing like this
client_fn()
{
...
input inp1;
output * pOutput = NULL;
ns1_func1(&inp1, pOutput);
if(pOutput == NULL)
{
cout<<"pOut is NULL\n";
return ERR;
}
else
{
// retrive output values from pOutput
}
...
}
I am always getting pOutput as NULL after call to ns1_func1 in spite of allocating pOutput from the server using soap_new_Output(soap, -1).
Also, my understanding is that we should use soap_new_X to allocate memory which gets automatically deallocated when we call soap_destroy. Pls correct me if I am wrong.
Basically I am struggling with no knowledge about who is supposed to take care of memory allocation/deallocation in such cases.
Any help would be great.