159191Skris=pod
259191Skris
359191Skris=head1 NAME
459191Skris
5291721SjkimBUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow - simple
6291721Sjkimcharacter array structure
759191Skris
8291721SjkimBUF_strdup, BUF_strndup, BUF_memdup, BUF_strlcpy, BUF_strlcat -
9291721Sjkimstandard C library equivalents
10291721Sjkim
1159191Skris=head1 SYNOPSIS
1259191Skris
1359191Skris #include <openssl/buffer.h>
1459191Skris
1559191Skris BUF_MEM *BUF_MEM_new(void);
1659191Skris
1759191Skris void	BUF_MEM_free(BUF_MEM *a);
1859191Skris
1959191Skris int	BUF_MEM_grow(BUF_MEM *str, int len);
2059191Skris
21291721Sjkim char *BUF_strdup(const char *str);
2259191Skris
23291721Sjkim char *BUF_strndup(const char *str, size_t siz);
24291721Sjkim
25291721Sjkim void *BUF_memdup(const void *data, size_t siz);
26291721Sjkim
27291721Sjkim size_t BUF_strlcpy(char *dst, const char *src, size_t size);
28291721Sjkim
29291721Sjkim size_t BUF_strlcat(char *dst, const char *src, size_t size);
30291721Sjkim
3159191Skris=head1 DESCRIPTION
3259191Skris
3359191SkrisThe buffer library handles simple character arrays. Buffers are used for
3459191Skrisvarious purposes in the library, most notably memory BIOs.
3559191Skris
3659191SkrisBUF_MEM_new() allocates a new buffer of zero size.
3759191Skris
3859191SkrisBUF_MEM_free() frees up an already existing buffer. The data is zeroed
3959191Skrisbefore freeing up in case the buffer contains sensitive data.
4059191Skris
4159191SkrisBUF_MEM_grow() changes the size of an already existing buffer to
4259191SkrisB<len>. Any data already in the buffer is preserved if it increases in
4359191Skrissize.
4459191Skris
45291721SjkimBUF_strdup(), BUF_strndup(), BUF_memdup(), BUF_strlcpy() and
46291721SjkimBUF_strlcat() are equivalents of the standard C library functions. The
47291721Sjkimdup() functions use OPENSSL_malloc() underneath and so should be used
48291721Sjkimin preference to the standard library for memory leak checking or
49291721Sjkimreplacing the malloc() function.
5059191Skris
51291721SjkimMemory allocated from these functions should be freed up using the
52291721SjkimOPENSSL_free() function.
5359191Skris
54291721SjkimBUF_strndup makes the explicit guarantee that it will never read past
55291721Sjkimthe first B<siz> bytes of B<str>.
56291721Sjkim
5759191Skris=head1 RETURN VALUES
5859191Skris
5959191SkrisBUF_MEM_new() returns the buffer or NULL on error.
6059191Skris
6159191SkrisBUF_MEM_free() has no return value.
6259191Skris
6359191SkrisBUF_MEM_grow() returns zero on error or the new size (i.e. B<len>).
6459191Skris
6559191Skris=head1 SEE ALSO
6659191Skris
6759191SkrisL<bio(3)|bio(3)>
6859191Skris
6959191Skris=head1 HISTORY
7059191Skris
7159191SkrisBUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all
7268651Skrisversions of SSLeay and OpenSSL. BUF_strdup() was added in SSLeay 0.8.
7359191Skris
7459191Skris=cut
75