various improvements
[rrq/rrqforth.git] / adoc / p_unstream.adoc
1 // stdio.asm:   WORD p_unstream,'UNSTREAM',fasm
2
3 anchor:p_unstream[]
4
5 === Word: UNSTREAM
6 ....
7 Data stack: ( stream* -- )
8 ....
9
10 "UNSTREAM" is a function word that releases the memory allocated for a
11 stream, and closes the associated file if it's a file stream.
12
13 ==== File descriptor backed stream
14
15 This kind of stream has the stream header as a prefix within the
16 allocated memory. Thus, stream* is the base address for the memory to
17 reclaim, and the size of this is determined from the cell at (stream*
18 + 16) plus the 32 bytes head itself.
19
20 ==== Memory block backed STREAM
21
22 This kind of stream has a separate header which points at the memory
23 area to reclaim. The cell at stream* is the base address, and the cell
24 at (stream* + 16) is its size.