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