RT 2517: Various typo's.
[openssl.git] / doc / crypto / buffer.pod
1 =pod
2
3 =head1 NAME
4
5 BUF_MEM_new, BUF_MEM_free, BUF_MEM_grow, BUF_strdup - simple
6 character arrays structure
7
8 =head1 SYNOPSIS
9
10  #include <openssl/buffer.h>
11
12  BUF_MEM *BUF_MEM_new(void);
13
14  void   BUF_MEM_free(BUF_MEM *a);
15
16  int    BUF_MEM_grow(BUF_MEM *str, int len);
17
18  char * BUF_strdup(const char *str);
19
20 =head1 DESCRIPTION
21
22 The buffer library handles simple character arrays. Buffers are used for
23 various purposes in the library, most notably memory BIOs.
24
25 The library uses the BUF_MEM structure defined in buffer.h:
26
27  typedef struct buf_mem_st
28  {
29         int length;     /* current number of bytes */
30         char *data;
31         int max;        /* size of buffer */
32  } BUF_MEM;
33
34 B<length> is the current size of the buffer in bytes, B<max> is the amount of
35 memory allocated to the buffer. There are three functions which handle these
36 and one "miscellaneous" function.
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() copies a null terminated string into a block of allocated
48 memory and returns a pointer to the allocated block.
49 Unlike the standard C library strdup() this function uses OPENSSL_malloc() and so
50 should be used in preference to the standard library strdup() because it can
51 be used for memory leak checking or replacing the malloc() function.
52
53 The memory allocated from BUF_strdup() should be freed up using the OPENSSL_free()
54 function.
55
56 =head1 RETURN VALUES
57
58 BUF_MEM_new() returns the buffer or NULL on error.
59
60 BUF_MEM_free() has no return value.
61
62 BUF_MEM_grow() returns zero on error or the new size (i.e. B<len>).
63
64 =head1 SEE ALSO
65
66 L<bio(3)|bio(3)>
67
68 =head1 HISTORY
69
70 BUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all
71 versions of SSLeay and OpenSSL. BUF_strdup() was added in SSLeay 0.8.
72
73 =cut