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 2017-09-15 "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 ():
35 _POSIX_C_SOURCE\ >=\ 200809L
45 function opens a stream for writing to a memory buffer.
46 The function dynamically allocates the buffer,
47 and the buffer automatically grows as needed.
48 Initially, the buffer has a size of zero.
49 After closing the stream, the caller should
53 The locations pointed to by
57 are used to report, respectively,
58 the current location and the size of the buffer.
59 The locations referred to by these pointers are updated
60 each time the stream is flushed
62 and when the stream is closed
64 These values remain valid only as long as the caller
65 performs no further output on the stream.
66 If further output is performed, then the stream
67 must again be flushed before trying to access these values.
69 A null byte is maintained at the end of the buffer.
72 included in the size value stored at
75 The stream maintains the notion of a current position,
76 which is initially zero (the start of the buffer).
77 Each write operation implicitly adjusts the buffer position.
78 The stream's buffer position can be explicitly changed with
82 Moving the buffer position past the end
83 of the data already written fills the intervening space with
87 .BR open_wmemstream ()
89 .BR open_memstream (),
90 but operates on wide characters instead of bytes.
92 Upon successful completion,
95 .BR open_wmemstream ()
99 Otherwise, NULL is returned and
101 is set to indicate the error.
103 .BR open_memstream ()
104 was already available in glibc 1.0.x.
105 .BR open_wmemstream ()
106 is available since glibc 2.4.
108 For an explanation of the terms used in this section, see
114 Interface Attribute Value
116 .BR open_memstream (),
119 T} Thread safety MT-Safe
124 These functions are not specified in POSIX.1-2001,
125 and are not widely available on other systems.
127 There is no file descriptor associated with the file stream
128 returned by these functions
131 will return an error if called on the returned stream).
133 In glibc before version 2.7, seeking past the end of a stream created by
134 .BR open_memstream ()
135 does not enlarge the buffer; instead the
137 call fails, returning \-1.
138 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=1996