fmemopen.3: Rework description of 'buf' and 'len' arguments

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2016-03-09 03:41:42 +01:00
parent 58c55bb87b
commit 9c8b5ebfc4
1 changed files with 22 additions and 15 deletions

View File

@ -93,6 +93,28 @@ is relative to the end of the buffer (i.e., the value specified by the
.I size
argument), rather than the current string length.
.PP
If
.I buf
is specified as NULL, then
.BR fmemopen ()
allocates a buffer of
.I size
bytes.
This is useful for an application that wants to write data to
a temporary buffer and then read it back again.
The initial position is set to the start of the buffer.
The buffer is automatically freed when the stream is closed.
Note that the caller has no way to obtain a pointer to the
temporary buffer allocated by this call (but see
.BR open_memstream ()
below).
.PP
If
.I buf
is not NULL, then it should point to a buffer of at least
.I len
bytes allocated by the caller.
.PP
When a stream that has been opened for writing is flushed
.RB ( fflush (3))
or closed
@ -134,21 +156,6 @@ A read from the buffer will indicate end-of-file
only when the file pointer advances
.I size
bytes past the start of the buffer.
.PP
If
.I buf
is specified as NULL, then
.BR fmemopen ()
dynamically allocates a buffer
.I size
bytes long.
This is useful for an application that wants to write data to
a temporary buffer and then read it back again.
The buffer is automatically freed when the stream is closed.
Note that the caller has no way to obtain a pointer to the
temporary buffer allocated by this call (but see
.BR open_memstream ()
below).
The
.BR open_memstream ()