BUF_MEM_new.pod 2.1 KB

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