chiark / gitweb /
Change interface for @dstr_vputf@.
[mLib] / man / dstr.3
index 998e3f3260a3a69a8ffd04996fe91cbb66365c87..b7317157bf145652c7eef9eb14a30dc0fa1a7bfd 100644 (file)
@@ -19,7 +19,8 @@
 ..
 .ie t .ds o \(bu
 .el .ds o o
-.TH dstr 3 "8 May 1999" "mLib"
+.TH dstr 3 "8 May 1999" "Straylight/Edgeware" "mLib utilities library"
+.SH NAME
 dstr \- a simple dynamic string type
 .\" @dstr_create
 .\" @dstr_destroy
@@ -62,7 +63,7 @@ dstr \- a simple dynamic string type
 .BI "void dstr_putc(dstr *" d ", char " ch );
 .BI "void dstr_putz(dstr *" d );
 .BI "void dstr_puts(dstr *" d ", const char *" s );
-.BI "int dstr_vputf(dstr *" d ", va_list " ap );
+.BI "int dstr_vputf(dstr *" d ", va_list *" ap );
 .BI "int dstr_putf(dstr *" d ", ...);"
 .BI "void dstr_putd(dstr *" d ", const dstr *" p );
 .BI "void dstr_putm(dstr *" d ", const void *" p ", size_t " sz );
@@ -103,6 +104,7 @@ typedef struct dstr {
   char *buf;           /* Pointer to string buffer */
   size_t sz;           /* Size of the buffer */
   size_t len;          /* Length of the string */
+  arena *a;            /* Pointer to arena */
 } dstr;
 .VE
 The
@@ -150,7 +152,7 @@ is zero, then
 is a null pointer.
 .hP \*o
 At all times,
-.BI sz " >= " len\fR.
+.BR sz " \(>= " len.
 .PP
 Note that there is no equivalent of the standard C distinction between
 the empty string (a pointer to an array of characters whose first
@@ -159,6 +161,14 @@ element is zero) and the nonexistent string (a null pointer).  Any
 whose
 .B len
 is zero is an empty string.
+.PP
+The
+.I a
+member refers to the arena from which the string's buffer has been
+allocated.  Immediately after creation, this is set to be
+.BR arena_stdlib (3);
+you can set it to point to any other arena of your choice before the
+buffer is allocated.
 .SS "Creation and destruction"
 The caller is responsible for allocating the
 .B dstr
@@ -330,12 +340,15 @@ The function
 .B dstr_vputf
 provides access to the `guts' of
 .BR dstr_putf :
-given a format string and a
-.B va_list
-pointer, it will format the arguments according to the format string,
-just as
+given a format string and a pointer to a
+.BR va_list
+it will format the arguments according to the format string, just as
 .B dstr_putf
-does.
+does.  (Note: that's a
+.BR "va_list *" ,
+not a plain
+.BR va_list ,
+so that it gets updated properly on exit.)
 .PP
 The function
 .B dstr_putd