buffer.pod 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. =pod
  2. =head1 NAME
  3. BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow - simple
  4. character array structure
  5. BUF_strdup, BUF_strndup, BUF_memdup, BUF_strlcpy, BUF_strlcat -
  6. standard C library equivalents
  7. =head1 SYNOPSIS
  8. #include <openssl/buffer.h>
  9. BUF_MEM *BUF_MEM_new(void);
  10. void BUF_MEM_free(BUF_MEM *a);
  11. int BUF_MEM_grow(BUF_MEM *str, int len);
  12. char *BUF_strdup(const char *str);
  13. char *BUF_strndup(const char *str, size_t siz);
  14. void *BUF_memdup(const void *data, size_t siz);
  15. size_t BUF_strlcpy(char *dst, const char *src, size_t size);
  16. size_t BUF_strlcat(char *dst, const char *src, size_t size);
  17. size_t BUF_strnlen(const char *str, size_t maxlen);
  18. =head1 DESCRIPTION
  19. The buffer library handles simple character arrays. Buffers are used for
  20. various purposes in the library, most notably memory BIOs.
  21. BUF_MEM_new() allocates a new buffer of zero size.
  22. BUF_MEM_free() frees up an already existing buffer. The data is zeroed
  23. before freeing up in case the buffer contains sensitive data.
  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_strdup(), BUF_strndup(), BUF_memdup(), BUF_strlcpy(),
  28. BUF_strlcat() and BUF_strnlen are equivalents of the standard C
  29. library functions. The dup() functions use OPENSSL_malloc() underneath
  30. and so should be used in preference to the standard library for memory
  31. leak checking or replacing the malloc() function.
  32. Memory allocated from these functions should be freed up using the
  33. OPENSSL_free() function.
  34. BUF_strndup makes the explicit guarantee that it will never read past
  35. the first B<siz> bytes of B<str>.
  36. =head1 RETURN VALUES
  37. BUF_MEM_new() returns the buffer or NULL on error.
  38. BUF_MEM_free() has no return value.
  39. BUF_MEM_grow() returns zero on error or the new size (i.e. B<len>).
  40. =head1 SEE ALSO
  41. L<bio(3)|bio(3)>
  42. =head1 HISTORY
  43. BUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all
  44. versions of SSLeay and OpenSSL. BUF_strdup() was added in SSLeay 0.8.
  45. =cut