buffer-write1 ( byte: fixnum buffer: buffer -- ) (original) (raw)

buffer-write1 ( byte: fixnum buffer: buffer -- )
Factor handbook » The language » Collections » Locked I/O buffers

Prev: buffer-read-until ( seps buffer: buffer -- byte-array sep/f )
Next: buffer-write ( c-ptr n buffer: buffer -- )

Vocabulary
io.buffers

Inputs

byte a byte
buffer a buffer

Outputs
None

Word description
Appends a single byte to a buffer.

Warning
This word will corrupt memory if the buffer is full.

Examples

USING: destructors io.buffers kernel prettyprint ; 100 [ 237 over buffer-write1 buffer-pop ] with-disposal .
237

Definition

USING: accessors alien.accessors kernel typed ;

IN: io.buffers

TYPED: buffer-write1 ( byte: fixnum buffer: buffer -- )
[ [ ptr>> ] [ fill>> ] bi set-alien-unsigned-1 ]
[ 1 swap buffer+ ] bi ; inline