1 .\" Copyright 2005, 2012, 2016 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" Distributed under the GPL.
7 .\" 2008-12-04, Petr Baudis <pasky@suse.cz>: Document open_wmemstream()
9 .TH OPEN_MEMSTREAM 3 2021-03-22 "GNU" "Linux Programmer's Manual"
11 open_memstream, open_wmemstream \- open a dynamic memory buffer stream
16 .BI "FILE *open_memstream(char **" ptr ", size_t *" sizeloc );
20 .BI "FILE *open_wmemstream(wchar_t **" ptr ", size_t *" sizeloc );
24 Feature Test Macro Requirements for glibc (see
25 .BR feature_test_macros (7)):
28 .BR open_memstream (),
29 .BR open_wmemstream ():
32 _POSIX_C_SOURCE >= 200809L
39 function opens a stream for writing to a memory buffer.
40 The function dynamically allocates the buffer,
41 and the buffer automatically grows as needed.
42 Initially, the buffer has a size of zero.
43 After closing the stream, the caller should
47 The locations pointed to by
51 are used to report, respectively,
52 the current location and the size of the buffer.
53 The locations referred to by these pointers are updated
54 each time the stream is flushed
56 and when the stream is closed
58 These values remain valid only as long as the caller
59 performs no further output on the stream.
60 If further output is performed, then the stream
61 must again be flushed before trying to access these values.
63 A null byte is maintained at the end of the buffer.
66 included in the size value stored at
69 The stream maintains the notion of a current position,
70 which is initially zero (the start of the buffer).
71 Each write operation implicitly adjusts the buffer position.
72 The stream's buffer position can be explicitly changed with
76 Moving the buffer position past the end
77 of the data already written fills the intervening space with
81 .BR open_wmemstream ()
83 .BR open_memstream (),
84 but operates on wide characters instead of bytes.
86 Upon successful completion,
89 .BR open_wmemstream ()
93 Otherwise, NULL is returned and
95 is set to indicate the error.
98 was already available in glibc 1.0.x.
99 .BR open_wmemstream ()
100 is available since glibc 2.4.
102 For an explanation of the terms used in this section, see
110 Interface Attribute Value
112 .BR open_memstream (),
113 .BR open_wmemstream ()
114 T} Thread safety MT-Safe
121 These functions are not specified in POSIX.1-2001,
122 and are not widely available on other systems.
124 There is no file descriptor associated with the file stream
125 returned by these functions
128 will return an error if called on the returned stream).
130 In glibc before version 2.7, seeking past the end of a stream created by
131 .BR open_memstream ()
132 does not enlarge the buffer; instead the
134 call fails, returning \-1.
135 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=1996