Re: [gnet] http api question



On Wednesday 13 April 2005 01:43, David Sowa wrote:

Hi David,

> I'm looking at the GConnHttp documentation and it the description of the
> GConnHttpEvent it says this:
>
> GNET_CONN_HTTP_DATA_PARTIAL: data has been read. The buffer is caller-owned
> (ie. owned by GNet), but may be truncated to zero length using the
> appropriate GString methods. You must not free the buffer
>
> Can this buffer really be manipulated as a GString?  I don't see any way to
> get a GString pointer.

No, this buffer can't be manipulated as a GString. The first version of 
GConnHttp used a GString as buffer, but that wouldn't have worked in GLib-1.2 
(because it can handle embedded 0s only since GLib-2.0), so it was changed to 
the way it is now. Looks like I forgot to update this part of the 
documentation.


> I was hoping to use the data at the callback level without doing yet
> another buffer copy.

The designated way to get to the partial or complete data is 
gnet_conn_http_steal_buffer() now, which at the moment not only involves a 
buffer copy, but also seems to leak the original buffer.

The code could certainly be improved quite a bit. I'll have a look through it 
and fix the memory leaks and make sure gnet_conn_http_steal_buffer() does not 
involve a buffer copy in the next release.

Cheers
 -Tim



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]