More doc cleanup
[openssl.git] / doc / crypto / BUF_MEM_new.pod
1 =pod
2
3 =head1 NAME
4
5 BUF_MEM_FLAG_SECURE,
6 BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow
7 BUF_MEM_grow_clean, BUF_reverse
8 - simple character array structure
9
10 standard C library equivalents
11
12 =head1 SYNOPSIS
13
14  #include <openssl/buffer.h>
15
16  BUF_MEM *BUF_MEM_new(void);
17
18  #define BUF_MEM_FLAG_SECURE
19
20  BUF_MEM *BUF_MEM_new_ex(unsigned long flags);
21
22  void BUF_MEM_free(BUF_MEM *a);
23
24  int BUF_MEM_grow(BUF_MEM *str, int len);
25  size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
26
27  void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size);
28
29 =head1 DESCRIPTION
30
31 The buffer library handles simple character arrays. Buffers are used for
32 various purposes in the library, most notably memory BIOs.
33
34 BUF_MEM_new() allocates a new buffer of zero size.
35
36 BUF_MEM_new_ex() allocates a buffer with the specified flags.
37 The flag B<BUF_MEM_FLAG_SECURE> specifies that the B<data> pointer
38 should be allocated on the secure heap; see L<CRYPTO_secure_malloc(3)>.
39
40 BUF_MEM_free() frees up an already existing buffer. The data is zeroed
41 before freeing up in case the buffer contains sensitive data.
42
43 BUF_MEM_grow() changes the size of an already existing buffer to
44 B<len>. Any data already in the buffer is preserved if it increases in
45 size.
46
47 BUF_MEM_grow_clean() is similar to BUF_MEM_grow() but it sets any free'd
48 or additionally-allocated memory to zero.
49
50 BUF_reverse() reverses B<size> bytes at B<in> into B<out>.  If B<out>
51 is NULL, the array is reversed in-place.
52
53 =head1 RETURN VALUES
54
55 BUF_MEM_new() returns the buffer or NULL on error.
56
57 BUF_MEM_free() has no return value.
58
59 BUF_MEM_grow() and BUF_MEM_grow_clean() return
60 zero on error or the new size (i.e., B<len>).
61
62 =head1 SEE ALSO
63
64 L<bio(3)>,
65 L<CRYPTO_secure_malloc(3)>.
66
67 =head1 HISTORY
68
69 BUF_MEM_new_ex() was added in OpenSSL 1.1.0.
70
71 =head1 COPYRIGHT
72
73 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
74
75 Licensed under the OpenSSL license (the "License").  You may not use
76 this file except in compliance with the License.  You can obtain a copy
77 in the file LICENSE in the source distribution or at
78 L<https://www.openssl.org/source/license.html>.
79
80 =cut