Document BUF_strnlen
[openssl.git] / doc / crypto / buffer.pod
1 =pod
2
3 =head1 NAME
4
5 BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow - simple
6 character array structure
7
8 BUF_strdup, BUF_strndup, BUF_memdup, BUF_strlcpy, BUF_strlcat -
9 standard C library equivalents
10
11 =head1 SYNOPSIS
12
13  #include <openssl/buffer.h>
14
15  BUF_MEM *BUF_MEM_new(void);
16
17  void   BUF_MEM_free(BUF_MEM *a);
18
19  int    BUF_MEM_grow(BUF_MEM *str, int len);
20
21  char *BUF_strdup(const char *str);
22
23  char *BUF_strndup(const char *str, size_t siz);
24
25  void *BUF_memdup(const void *data, size_t siz);
26
27  size_t BUF_strlcpy(char *dst, const char *src, size_t size);
28
29  size_t BUF_strlcat(char *dst, const char *src, size_t size);
30
31  size_t BUF_strnlen(const char *str, size_t maxlen);
32
33 =head1 DESCRIPTION
34
35 The buffer library handles simple character arrays. Buffers are used for
36 various purposes in the library, most notably memory BIOs.
37
38 BUF_MEM_new() allocates a new buffer of zero size.
39
40 BUF_MEM_free() frees up an already existing buffer. The data is zeroed
41 before freeing up in case the buffer contains sensitive data.
42
43 BUF_MEM_grow() changes the size of an already existing buffer to
44 B<len>. Any data already in the buffer is preserved if it increases in
45 size.
46
47 BUF_strdup(), BUF_strndup(), BUF_memdup(), BUF_strlcpy(),
48 BUF_strlcat() and BUF_strnlen are equivalents of the standard C
49 library functions. The dup() functions use OPENSSL_malloc() underneath
50 and so should be used in preference to the standard library for memory
51 leak checking or replacing the malloc() function.
52
53 Memory allocated from these functions should be freed up using the
54 OPENSSL_free() function.
55
56 BUF_strndup makes the explicit guarantee that it will never read past
57 the first B<siz> bytes of B<str>.
58
59 =head1 RETURN VALUES
60
61 BUF_MEM_new() returns the buffer or NULL on error.
62
63 BUF_MEM_free() has no return value.
64
65 BUF_MEM_grow() returns zero on error or the new size (i.e. B<len>).
66
67 =head1 SEE ALSO
68
69 L<bio(3)|bio(3)>
70
71 =head1 HISTORY
72
73 BUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all
74 versions of SSLeay and OpenSSL. BUF_strdup() was added in SSLeay 0.8.
75
76 =cut