Deleted Added
full compact
BIO_s_mem.pod (1.1.1.4) BIO_s_mem.pod (1.1.1.5)
1=pod
2
3=head1 NAME
4
5BIO_s_secmem,
6BIO_s_mem, BIO_set_mem_eof_return, BIO_get_mem_data, BIO_set_mem_buf,
7BIO_get_mem_ptr, BIO_new_mem_buf - memory BIO
8

--- 45 unchanged lines hidden (view full) ---

54empty. If the B<v> is zero then an empty memory BIO will return EOF (that is
55it will return zero and BIO_should_retry(b) will be false. If B<v> is non
56zero then it will return B<v> when it is empty and it will set the read retry
57flag (that is BIO_read_retry(b) is true). To avoid ambiguity with a normal
58positive return value B<v> should be set to a negative value, typically -1.
59
60BIO_get_mem_data() sets *B<pp> to a pointer to the start of the memory BIOs data
61and returns the total amount of data available. It is implemented as a macro.
1=pod
2
3=head1 NAME
4
5BIO_s_secmem,
6BIO_s_mem, BIO_set_mem_eof_return, BIO_get_mem_data, BIO_set_mem_buf,
7BIO_get_mem_ptr, BIO_new_mem_buf - memory BIO
8

--- 45 unchanged lines hidden (view full) ---

54empty. If the B<v> is zero then an empty memory BIO will return EOF (that is
55it will return zero and BIO_should_retry(b) will be false. If B<v> is non
56zero then it will return B<v> when it is empty and it will set the read retry
57flag (that is BIO_read_retry(b) is true). To avoid ambiguity with a normal
58positive return value B<v> should be set to a negative value, typically -1.
59
60BIO_get_mem_data() sets *B<pp> to a pointer to the start of the memory BIOs data
61and returns the total amount of data available. It is implemented as a macro.
62Note the pointer returned by this call is informative, no transfer of ownership
63of this memory is implied. See notes on BIO_set_close().
62
63BIO_set_mem_buf() sets the internal BUF_MEM structure to B<bm> and sets the
64close flag to B<c>, that is B<c> should be either BIO_CLOSE or BIO_NOCLOSE.
65It is a macro.
66
67BIO_get_mem_ptr() places the underlying BUF_MEM structure in *B<pp>. It is
68a macro.
69

--- 39 unchanged lines hidden (view full) ---

109flag set can have unexpected outcome when the reads and writes to the
110BIO are intertwined. As documented above the BIO will be reset to the
111state after the last completed write operation. The effects of reads
112preceding that write operation cannot be undone.
113
114Calling BIO_get_mem_ptr() prior to a BIO_reset() call with
115BIO_FLAGS_NONCLEAR_RST set has the same effect as a write operation.
116
64
65BIO_set_mem_buf() sets the internal BUF_MEM structure to B<bm> and sets the
66close flag to B<c>, that is B<c> should be either BIO_CLOSE or BIO_NOCLOSE.
67It is a macro.
68
69BIO_get_mem_ptr() places the underlying BUF_MEM structure in *B<pp>. It is
70a macro.
71

--- 39 unchanged lines hidden (view full) ---

111flag set can have unexpected outcome when the reads and writes to the
112BIO are intertwined. As documented above the BIO will be reset to the
113state after the last completed write operation. The effects of reads
114preceding that write operation cannot be undone.
115
116Calling BIO_get_mem_ptr() prior to a BIO_reset() call with
117BIO_FLAGS_NONCLEAR_RST set has the same effect as a write operation.
118
119Calling BIO_set_close() with BIO_NOCLOSE orphans the BUF_MEM internal to the
120BIO, _not_ its actual data buffer. See the examples section for the proper
121method for claiming ownership of the data pointer for a deferred free operation.
122
117=head1 BUGS
118
119There should be an option to set the maximum size of a memory BIO.
120
121=head1 RETURN VALUES
122
123BIO_s_mem() and BIO_s_secmem() return a valid memory B<BIO_METHOD> structure.
124

--- 21 unchanged lines hidden (view full) ---

146Extract the BUF_MEM structure from a memory BIO and then free up the BIO:
147
148 BUF_MEM *bptr;
149
150 BIO_get_mem_ptr(mem, &bptr);
151 BIO_set_close(mem, BIO_NOCLOSE); /* So BIO_free() leaves BUF_MEM alone */
152 BIO_free(mem);
153
123=head1 BUGS
124
125There should be an option to set the maximum size of a memory BIO.
126
127=head1 RETURN VALUES
128
129BIO_s_mem() and BIO_s_secmem() return a valid memory B<BIO_METHOD> structure.
130

--- 21 unchanged lines hidden (view full) ---

152Extract the BUF_MEM structure from a memory BIO and then free up the BIO:
153
154 BUF_MEM *bptr;
155
156 BIO_get_mem_ptr(mem, &bptr);
157 BIO_set_close(mem, BIO_NOCLOSE); /* So BIO_free() leaves BUF_MEM alone */
158 BIO_free(mem);
159
160Extract the BUF_MEM ptr, claim ownership of the internal data and free the BIO
161and BUF_MEM structure:
154
162
163 BUF_MEM *bptr;
164 char *data;
165
166 BIO_get_mem_data(bio, &data);
167 BIO_get_mem_ptr(bio, &bptr);
168 BIO_set_close(mem, BIO_NOCLOSE); /* So BIO_free orphans BUF_MEM */
169 BIO_free(bio);
170 bptr->data = NULL; /* Tell BUF_MEM to orphan data */
171 BUF_MEM_free(bptr);
172 ...
173 free(data);
174
155=head1 COPYRIGHT
156
175=head1 COPYRIGHT
176
157Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
177Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
158
159Licensed under the Apache License 2.0 (the "License"). You may not use
160this file except in compliance with the License. You can obtain a copy
161in the file LICENSE in the source distribution or at
162L<https://www.openssl.org/source/license.html>.
163
164=cut
178
179Licensed under the Apache License 2.0 (the "License"). You may not use
180this file except in compliance with the License. You can obtain a copy
181in the file LICENSE in the source distribution or at
182L<https://www.openssl.org/source/license.html>.
183
184=cut