I've been spending some quality time with the memory management code
recently, albiet in an older gSoap version, but I can't answer your
question definitively for all cases.

The standard approach is to use soap_malloc() and the soap_new_*
methods to allocate data. This leverages the built-in garbage
collection system. I suppose one could implement his own system to
track allocations.

In you example, calling soap_end() after each could cause problems
depending on the content of ns1_FunctionResponse1. If that's an atomic
class or structure than the applications code will have complete
control over the allocation. If that contains data that needed to be
allocated inside the call, the invoking soap_end() may cause problems.

It looks like multiple calls into the generated methods may cause
allocated pointers to be retained in the linked lists, but I don't
know for sure. If so then you could do a soap_end() after the pair.
Give it a whirl!


--- In gsoap@yahoogroups.com, "partridge.brian" <[EMAIL PROTECTED]>
wrote:
>
> So just to confirm, in the following case:
> 
> // global soap struct maintaining a connection
> 
> __ns1__Function1(ns1__Function1, ns1__FunctionResponse1);
> // Create an object that maintains a reference to the response
> MyClass *pObj = new MyClass(ns1__FunctionResponse1);
> __ns1__Function2(ns1__Function2, ns1__FunctionResponse2);
> return pObj;
> 
> In this case I should call soap_end after each functions 1 and 2 and
> it wont invalidate anything that I need, right?  How should I cleanup
> response 2 before it goes out of scope at the return, soap_delete?
> What about response 1? Since pObj maintains a reference to response 1
> and is returned I think I should use soap_delete within ~MyClass.
> 
> Thanks for the help.
> 


Reply via email to