BUF_MEM_new.pod 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. BUF_MEM_grow() changes the size of an already existing buffer to
  24. B<len>. Any data already in the buffer is preserved if it increases in
  25. size.
  26. BUF_MEM_grow_clean() is similar to BUF_MEM_grow() but it sets any free'd
  27. or additionally-allocated memory to zero.
  28. BUF_reverse() reverses B<size> bytes at B<in> into B<out>. If B<in>
  29. is NULL, the array is reversed in-place.
  30. =head1 RETURN VALUES
  31. BUF_MEM_new() returns the buffer or NULL on error.
  32. BUF_MEM_free() has no return value.
  33. BUF_MEM_grow() and BUF_MEM_grow_clean() return
  34. zero on error or the new size (i.e., B<len>).
  35. =head1 SEE ALSO
  36. L<bio(7)>,
  37. L<CRYPTO_secure_malloc(3)>.
  38. =head1 HISTORY
  39. The BUF_MEM_new_ex() function was added in OpenSSL 1.1.0.
  40. =head1 COPYRIGHT
  41. Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
  42. Licensed under the Apache License 2.0 (the "License"). You may not use
  43. this file except in compliance with the License. You can obtain a copy
  44. in the file LICENSE in the source distribution or at
  45. L<https://www.openssl.org/source/license.html>.
  46. =cut