1 .\" Copyright 2005 walter harms (walter.harms@informatik.uni-oldenburg.de),
2 .\" and Copyright 2005, 2012, 2016 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
5 .\" Distributed under the GPL.
8 .\" 2008-12-04, Petr Baudis <pasky@suse.cz>: Document open_wmemstream()
10 .TH OPEN_MEMSTREAM 3 2015-03-29 "GNU" "Linux Programmer's Manual"
12 open_memstream, open_wmemstream \- open a dynamic memory buffer stream
17 .BI "FILE *open_memstream(char **" ptr ", size_t *" sizeloc );
21 .BI "FILE *open_wmemstream(wchar_t **" ptr ", size_t *" sizeloc );
25 Feature Test Macro Requirements for glibc (see
26 .BR feature_test_macros (7)):
29 .BR open_memstream (),
30 .BR open_wmemstream ():
36 _POSIX_C_SOURCE\ >=\ 200809L
46 function opens a stream for writing to a buffer.
47 The function dynamically allocates the buffer (in the manner of
49 and the buffer automatically grows as required.
50 After closing the stream, the caller should
54 The locations pointed to by
58 are used to report the current location and size of the buffer.
59 When the stream is closed
63 the locations pointed to by
67 are updated to contain, respectively, a pointer to the buffer and the
68 current size of the buffer.
69 These values remain valid only as long as the caller
70 performs no further output on the stream.
71 If further output is performed, then the stream
72 must again be flushed before trying to access these variables.
74 A null byte is maintained at the end of the buffer.
77 included in the size value stored at
80 The stream maintains the notion of a current position,
81 which is initially zero (the start of the buffer).
82 Each write operation implicitly adjusts the buffer position.
83 The stream's buffer position can be explicitly changed with
87 Moving the buffer position past the end
88 of the data already written fills the intervening space with
92 .BR open_wmemstream ()
94 .BR open_memstream (),
95 but operates on wide characters instead of bytes.
97 Upon successful completion,
100 .BR open_wmemstream ()
104 Otherwise, NULL is returned and
106 is set to indicate the error.
108 .BR open_memstream ()
109 was already available in glibc 1.0.x.
110 .BR open_wmemstream ()
111 is available since glibc 2.4.
113 For an explanation of the terms used in this section, see
119 Interface Attribute Value
121 .BR open_memstream (),
124 T} Thread safety MT-Safe
129 These functions are not specified in POSIX.1-2001,
130 and are not widely available on other systems.
132 There is no file descriptor associated with the file stream
133 returned by these functions
136 will return an error if called on the returned stream).
138 In glibc before version 2.7, seeking past the end of a stream created by
139 .BR open_memstream ()
140 does not enlarge the buffer; instead the
142 call fails, returning \-1.
143 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=1996