chiark / gitweb /
Update for new arena management.
[mLib] / man / lbuf.3
index beab46f3d18f50ab3f592e6ab8f59b90aa788d0a..e238a8cf9ea9d43113a5decde59b1299744d01e7 100644 (file)
@@ -15,9 +15,11 @@ lbuf \- split lines out of asynchronously received blocks
 .BI "void lbuf_close(lbuf *" b );
 .BI "size_t lbuf_free(lbuf *" b ", char **" p );
 .BI "void lbuf_snarf(lbuf *" b ", const void *" p ", size_t " sz );
+.BI "void lbuf_setsize(lbuf *" b ", size_t " sz );
 .BI "void lbuf_init(lbuf *" b ,
 .BI "               void (*" func ")(char *" s ", void *" p ),
 .BI "               void *" p );
+.BI "void lbuf_destroy(lbuf *" b );
 .fi
 .SH "DESCRIPTION"
 The declarations in
@@ -55,11 +57,21 @@ function to which the line buffer should pass completed lines of text.
 A pointer argument to be passed to the function when a completed line of
 text arrives.
 .PP
-Since the line buffer requires no memory except for the actual
-.B lbuf
-object, and doesn't hook itself onto anything else, it can just be
-thrown away when you don't want it any more.  No explicit finalization
-is required.
+The amount of memory set aside for reading lines is configurable.  It
+may be set by calling
+.B lbuf_setsize
+at any time when the buffer is empty.  The default limit is 256 bytes.
+Lines longer than the limit are truncated.  By default, the buffer is
+allocated from the current arena,
+.BR arena_global (3);
+this may be changed by altering the buffer's
+.B a
+member to refer to a different arena at any time when the buffer is
+unallocated.
+.PP
+A line buffer must be destroyed after use by calling
+.BR lbuf_destroy ,
+passing it the address of the buffer block.
 .SS "Inserting data into the buffer"
 There are two interfaces for inserting data into the buffer.  One's much
 simpler than the other, although it's less expressive.