Home | History | Annotate | Line # | Download | only in man3
      1 =pod
      2 
      3 =head1 NAME
      4 
      5 BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow,
      6 BUF_MEM_grow_clean, BUF_reverse
      7 - simple character array structure
      8 
      9 =head1 SYNOPSIS
     10 
     11  #include <openssl/buffer.h>
     12 
     13  BUF_MEM *BUF_MEM_new(void);
     14 
     15  BUF_MEM *BUF_MEM_new_ex(unsigned long flags);
     16 
     17  void BUF_MEM_free(BUF_MEM *a);
     18 
     19  int BUF_MEM_grow(BUF_MEM *str, int len);
     20  size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
     21 
     22  void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size);
     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 If the argument is NULL, nothing is done.
     38 
     39 BUF_MEM_grow() changes the size of an already existing buffer to
     40 B<len>. Any data already in the buffer is preserved if it increases in
     41 size.
     42 
     43 BUF_MEM_grow_clean() is similar to BUF_MEM_grow() but it sets any free'd
     44 or additionally-allocated memory to zero.
     45 
     46 BUF_reverse() reverses B<size> bytes at B<in> into B<out>.  If B<in>
     47 is NULL, the array is reversed in-place.
     48 
     49 =head1 RETURN VALUES
     50 
     51 BUF_MEM_new() returns the buffer or NULL on error.
     52 
     53 BUF_MEM_free() has no return value.
     54 
     55 BUF_MEM_grow() and BUF_MEM_grow_clean() return
     56 zero on error or the new size (i.e., B<len>).
     57 
     58 =head1 SEE ALSO
     59 
     60 L<bio(7)>,
     61 L<CRYPTO_secure_malloc(3)>.
     62 
     63 =head1 HISTORY
     64 
     65 The BUF_MEM_new_ex() function was added in OpenSSL 1.1.0.
     66 
     67 =head1 COPYRIGHT
     68 
     69 Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
     70 
     71 Licensed under the Apache License 2.0 (the "License").  You may not use
     72 this file except in compliance with the License.  You can obtain a copy
     73 in the file LICENSE in the source distribution or at
     74 L<https://www.openssl.org/source/license.html>.
     75 
     76 =cut
     77