2 .\" Copyright 2005, 2012, 2016 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: GPL-1.0-or-later
6 .\" 2008-12-04, Petr Baudis <pasky@suse.cz>: Document open_wmemstream()
8 .TH open_memstream 3 (date) "Linux man-pages (unreleased)"
10 open_memstream, open_wmemstream \- open a dynamic memory buffer stream
13 .RI ( libc ", " \-lc )
18 .BI "FILE *open_memstream(char **" ptr ", size_t *" sizeloc );
22 .BI "FILE *open_wmemstream(wchar_t **" ptr ", size_t *" sizeloc );
26 Feature Test Macro Requirements for glibc (see
27 .BR feature_test_macros (7)):
30 .BR open_memstream (),
31 .BR open_wmemstream ():
34 _POSIX_C_SOURCE >= 200809L
41 function opens a stream for writing to a memory buffer.
42 The function dynamically allocates the buffer,
43 and the buffer automatically grows as needed.
44 Initially, the buffer has a size of zero.
45 After closing the stream, the caller should
49 The locations pointed to by
53 are used to report, respectively,
54 the current location and the size of the buffer.
55 The locations referred to by these pointers are updated
56 each time the stream is flushed
58 and when the stream is closed
60 These values remain valid only as long as the caller
61 performs no further output on the stream.
62 If further output is performed, then the stream
63 must again be flushed before trying to access these values.
65 A null byte is maintained at the end of the buffer.
68 included in the size value stored at
71 The stream maintains the notion of a current position,
72 which is initially zero (the start of the buffer).
73 Each write operation implicitly adjusts the buffer position.
74 The stream's buffer position can be explicitly changed with
78 Moving the buffer position past the end
79 of the data already written fills the intervening space with
83 .BR open_wmemstream ()
85 .BR open_memstream (),
86 but operates on wide characters instead of bytes.
88 Upon successful completion,
91 .BR open_wmemstream ()
95 Otherwise, NULL is returned and
97 is set to indicate the error.
99 For an explanation of the terms used in this section, see
107 Interface Attribute Value
109 .BR open_memstream (),
110 .BR open_wmemstream ()
111 T} Thread safety MT-Safe
120 .BR open_memstream ()
123 .BR open_wmemstream ()
126 There is no file descriptor associated with the file stream
127 returned by these functions
130 will return an error if called on the returned stream).
132 Before glibc 2.7, seeking past the end of a stream created by
133 .BR open_memstream ()
134 does not enlarge the buffer; instead the
136 call fails, returning \-1.
137 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=1996