--- In gsoap@yahoogroups.com, "rabidcicada" <rabidcic...@...> wrote: > > > > --- In gsoap@yahoogroups.com, "alestrcek" <alestrcek@> wrote: > > > > [bump] > > No one has worked with xsd__base64Binary before? > > [/bump] > > > > Regards, > > Ales > > > > --- In gsoap@yahoogroups.com, "alestrcek" <alestrcek@> wrote: > > > > > > Hi all, > > > > > > I have SOAP server code, which sends file(s) back to the client upon WS > > > request. Data is xsd__base64Binary object, which - as all other gSOAP > > > arrays - has a member for data -> char* __ptr and member for data size -> > > > int __size. This class was generated from wsdl, in which I defined the > > > data as xsd:base64Binary. > > > In my code, I read the file into unsigned char*, and I want copy it to > > > the __ptr member of the xsd__base64Binary object. Since this object is > > > allocated on stack, all I have to do is memcpy my data to __ptr, and set > > > __size. Everything works and is OK, however the problem is that I see no > > > way of freeing the memory for __ptr. If I wish to copy the data into it, > > > I must allocate memory, and gSOAP does not provide any wrapper for char* > > > memory allocation (like soap_new_ns1__someClass(...)) They exist for > > > custom objects, strings, dates, decimals etc. but none for char*. There > > > is a wrapper function for xsd__base64Binary, but it does not allocate > > > memory for __ptr. So I have no other option, than to call: > > > this->fileData->File->Data.__ptr = new char[data_len]; > > > Then, there is no way to 'manually' delete this char*. > > > xsd__base64Binary's desctructor is already defined in stub header > > > (virtual ~xsd__base64Binary() { }), and when I leave the scope of this > > > SOAP method, I have no control over objects that were left on heap. > > > > > > So... how to allocate memory via gSOAP's internal 'garbage collector', or > > > how to free this memory allocated with new? I can't believe that no one > > > thought of this problem with xsd__base64Binary class? I also didn't find > > > any samples for server code, only client. > > > > > > Thanks for any answers. > > > > > > Regards, > > > Ales > > > > > > > Sorry there.....Didn't see this question: > > gSOAP provides a raw malloc function for you to use for stuff like this. > It's called soap_malloc(). > > From the FAQ:http://www.cs.fsu.edu/~engelen/soapfaq.html > void *soap_malloc(size_t n); // gSOAP 1.X > void *soap_malloc(struct soap *soap, size_t n); // gSOAP 2.X > > Use those to allocate arbitrary sized datastructures that are still garbage > collected etc. >
Excellent, it works, thank you very much! Regards, Ales