Backwards-compatibility subject to OPENSSL_API_COMPAT
[openssl.git] / doc / crypto / buffer.pod
1 =pod
2
3 =head1 NAME
4
5 BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow - simple
6 character array structure
7
8 standard C library equivalents
9
10 =head1 SYNOPSIS
11
12  #include <openssl/buffer.h>
13
14  BUF_MEM *BUF_MEM_new(void);
15
16  #define BUF_MEM_FLAG_SECURE
17
18  BUF_MEM *BUF_MEM_new_ex(unsigned long flags);
19
20  void   BUF_MEM_free(BUF_MEM *a);
21
22  int    BUF_MEM_grow(BUF_MEM *str, int len);
23
24 =head1 DESCRIPTION
25
26 The buffer library handles simple character arrays. Buffers are used for
27 various purposes in the library, most notably memory BIOs.
28
29 BUF_MEM_new() allocates a new buffer of zero size.
30
31 BUF_MEM_new_ex() allocates a buffer with the specified flags.
32 The flag B<BUF_MEM_FLAG_SECURE> specifies that the B<data> pointer
33 should be allocated on the secure heap; see L<CRYPTO_secure_malloc(3)>.
34
35 BUF_MEM_free() frees up an already existing buffer. The data is zeroed
36 before freeing up in case the buffer contains sensitive data.
37
38 BUF_MEM_grow() changes the size of an already existing buffer to
39 B<len>. Any data already in the buffer is preserved if it increases in
40 size.
41
42 =head1 RETURN VALUES
43
44 BUF_MEM_new() returns the buffer or NULL on error.
45
46 BUF_MEM_free() has no return value.
47
48 BUF_MEM_grow() returns zero on error or the new size (i.e. B<len>).
49
50 =head1 SEE ALSO
51
52 L<bio(3)>,
53 L<CRYPTO_secure_malloc(3)>.
54
55 =head1 HISTORY
56
57 BUF_MEM_new_ex() was added in OpenSSL 1.1.0.
58
59 =cut