[Prev][Next][Index][Thread]

Re: HTStream and HTFWriter_new and _free




> if you create a HTStream object with HTFWriter_new(),
> memory is allocated.
> At what time it is released ?
> How can I release it ?
> Is it released when calling HTLibTerminate() ?
> 
> There is a function PRIVATE HTFWriter_free(), but it seems
> to be, that it is never called. And It's not a PUBLIC function.

The stream is freed of automatically! Think of the streams as objects
hanging of each other making a stream chain:

	STREAM_1 --> STREAM_2 --> ... --> STREAM_n

STREAM_1 is the first stream where data is put directly from the network and
your HTFWriter stream comes in as STREAM_n. When STREAM_1 is freed when no
more data is arriving and the socket closed, all stream objects down the chain
are automatically freed. You can see this by looking into the free method in
any of the streams. It looks to see if there is a stream object hanging off it
(normally called the target or sink) or it is the last element in the chain.
If a target is found then it is freed.

BTW: A stream doesn't have to have a output, a good example of the opposite is the
HTBlackHole stream that just absorbs data!

You can see a nicer picture of this at

	http://www.w3.org/hypertext/WWW/Library/User/Guide/Stream.html


--

Henrik Frystyk                                          frystyk@W3.org
World-Wide Web Consortium,                              Tel + 1 617 258 8143
MIT/LCS, NE43-356					Fax + 1 617 258 8682
77 Massachusetts Avenue
Cambridge MA 02154, USA