1 .\" $OpenBSD: BUF_MEM_new.3,v 1.14 2018/03/23 04:34:23 schwarze Exp $
2 .\" OpenSSL doc/crypto/buffer.pod 18edda0f Sep 20 03:28:54 2000 +0000
3 .\" not merged: 74924dcb, 58e3457a, 21b0fa91, 7644a9ae
4 .\" OpenSSL doc/crypto/BUF_MEM_new.pod 53934822 Jun 9 16:39:19 2016 -0400
5 .\" not merged: c952780c, 91da5e77
6 .\" OpenSSL doc/man3/BUF_MEM_new.pod 498180de Dec 12 15:35:09 2016 +0300
8 .\" This file was written by Ralf S. Engelschall <rse@openssl.org>.
9 .\" Copyright (c) 1999, 2000, 2016 The OpenSSL Project. All rights reserved.
11 .\" Redistribution and use in source and binary forms, with or without
12 .\" modification, are permitted provided that the following conditions
15 .\" 1. Redistributions of source code must retain the above copyright
16 .\" notice, this list of conditions and the following disclaimer.
18 .\" 2. Redistributions in binary form must reproduce the above copyright
19 .\" notice, this list of conditions and the following disclaimer in
20 .\" the documentation and/or other materials provided with the
23 .\" 3. All advertising materials mentioning features or use of this
24 .\" software must display the following acknowledgment:
25 .\" "This product includes software developed by the OpenSSL Project
26 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
28 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
29 .\" endorse or promote products derived from this software without
30 .\" prior written permission. For written permission, please contact
31 .\" openssl-core@openssl.org.
33 .\" 5. Products derived from this software may not be called "OpenSSL"
34 .\" nor may "OpenSSL" appear in their names without prior written
35 .\" permission of the OpenSSL Project.
37 .\" 6. Redistributions of any form whatsoever must retain the following
39 .\" "This product includes software developed by the OpenSSL Project
40 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
42 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
43 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
46 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
55 .Dd $Mdocdate: March 23 2018 $
62 .Nm BUF_MEM_grow_clean ,
65 .Nd simple character arrays structure
82 .Fo BUF_MEM_grow_clean
88 .Fa "unsigned char *out"
89 .Fa "const unsigned char *in"
97 The buffer library handles simple character arrays.
98 Buffers are used for various purposes in the library, most notably
103 structure defined in buffer.h:
105 typedef struct buf_mem_st
107 size_t length; /* current number of bytes */
109 size_t max; /* size of buffer */
114 is the current size of the buffer in bytes;
116 is the amount of memory allocated to the buffer.
117 There are three functions which handle these and one miscellaneous function.
120 allocates a new buffer of zero size.
123 frees up an already existing buffer.
124 The data is zeroed before freeing up in case the buffer contains
130 pointer, no action occurs.
133 changes the size of an already existing buffer to
135 Any data already in the buffer is preserved if it increases in size.
137 .Fn BUF_MEM_grow_clean
140 but it sets any freed or additionally allocated memory to zero.
154 is reversed in place.
157 copies a NUL terminated string into a block of allocated memory and
158 returns a pointer to the allocated block.
165 argument and will return
168 Its use in new programs is discouraged.
170 The memory allocated from
172 should be freed up using the
177 returns the buffer or
183 .Fn BUF_MEM_grow_clean
184 return zero on error or the new size (i.e.\&
193 appeared before SSLeay 0.8.
195 first appeared in SSLeay 0.8.
196 All these functions have been available since
199 .Fn BUF_MEM_grow_clean
200 first appeared in OpenSSL 0.9.7 and has been available since
204 first appeared in OpenSSL 1.0.0 and has been available since