5 BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow - simple
6 character array structure
8 BUF_strdup, BUF_strndup, BUF_memdup, BUF_strlcpy, BUF_strlcat -
9 standard C library equivalents
13 #include <openssl/buffer.h>
15 BUF_MEM *BUF_MEM_new(void);
17 void BUF_MEM_free(BUF_MEM *a);
19 int BUF_MEM_grow(BUF_MEM *str, int len);
21 char *BUF_strdup(const char *str);
23 char *BUF_strndup(const char *str, size_t siz);
25 void *BUF_memdup(const void *data, size_t siz);
27 size_t BUF_strlcpy(char *dst, const char *src, size_t size);
29 size_t BUF_strlcat(char *dst, const char *src, size_t size);
33 The buffer library handles simple character arrays. Buffers are used for
34 various purposes in the library, most notably memory BIOs.
36 BUF_MEM_new() allocates a new buffer of zero size.
38 BUF_MEM_free() frees up an already existing buffer. The data is zeroed
39 before freeing up in case the buffer contains sensitive data.
41 BUF_MEM_grow() changes the size of an already existing buffer to
42 B<len>. Any data already in the buffer is preserved if it increases in
45 BUF_strdup(), BUF_strndup(), BUF_memdup(), BUF_strlcpy() and
46 BUF_strlcat() are equivalents of the standard C library functions. The
47 dup() functions use OPENSSL_malloc() underneath and so should be used
48 in preference to the standard library for memory leak checking or
49 replacing the malloc() function.
51 Memory allocated from these functions should be freed up using the
52 OPENSSL_free() function.
54 BUF_strndup makes the explicit guarantee that it will never read past
55 the first B<siz> bytes of B<str>.
59 BUF_MEM_new() returns the buffer or NULL on error.
61 BUF_MEM_free() has no return value.
63 BUF_MEM_grow() returns zero on error or the new size (i.e. B<len>).
71 BUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all
72 versions of SSLeay and OpenSSL. BUF_strdup() was added in SSLeay 0.8.