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