hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit c1ded6f8a6dbd23f7ab10437147fe3b71533e127
parent 5bff8e0a193d4720b375a2c9fc2028500af5c0da
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 26 Jun 2021 13:27:23 -0400

bufio: further docs improvements

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mbufio/README | 8++++----
Mbufio/buffered.ha | 8++++++--
2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/bufio/README b/bufio/README @@ -6,11 +6,11 @@ Two streams are provided which can read from or write to byte slices. [[fixed]] uses a caller-supplied statically-allocated buffer for storage, producing an [[io::stream]] which reads from or writes to this buffer. In effect, this allows the caller to statically allocate a byte array, then produce an [[io::stream]] -which writes to or reads from it. +which writes to or reads from it. [[dynamic]] is similar, but it uses a +bufio-managed dynamically allocated buffer. This creates an [[io::stream]] which +efficiently soaks up writes into a dynamically allocated byte slice. -The [[dynamic]] stream is similar, but it uses a bufio-managed dynamically -allocated buffer. This creates an [[io::stream]] which efficiently soaks up -writes into a dynamically allocated byte slice, which may be accessed via +Both [[fixed]] and [[dynamic]] provide access to the underlying buffer via [[buffer]] or [[finish]]. The user may also call [[reset]], which empties the buffer but does not free the underlying storage, allowing the user to re-use the same buffer for many operations. diff --git a/bufio/buffered.ha b/bufio/buffered.ha @@ -24,8 +24,12 @@ export type bufstream = struct { // the desired buffer, or empty slices if read or write functionality is // disabled. The same buffer may not be used for both reads and writes. // -// The caller is responsible for closing the underlying stream and freeing the -// provided buffers after the buffered stream is closed. +// The caller is responsible for closing the underlying stream, and freeing the +// provided buffers if necessary, after the buffered stream is closed. +// +// let rbuf: [os::BUFSIZ] = [0...]; +// let wbuf: [os::BUFSIZ] = [0...]; +// let buffered = bufio::buffered(source, rbuf, wbuf); export fn buffered( src: *io::stream, rbuf: []u8,