1buffer(3)                           OpenSSL                          buffer(3)
2
3
4

NAME

6       BUF_MEM_new, BUF_MEM_free, BUF_MEM_grow, BUF_strdup - simple character
7       arrays structure
8

SYNOPSIS

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

DESCRIPTION

21       The buffer library handles simple character arrays. Buffers are used
22       for various purposes in the library, most notably memory BIOs.
23
24       The library uses the BUF_MEM structure defined in buffer.h:
25
26        typedef struct buf_mem_st
27        {
28               int length;     /* current number of bytes */
29               char *data;
30               int max;        /* size of buffer */
31        } BUF_MEM;
32
33       length is the current size of the buffer in bytes, max is the amount of
34       memory allocated to the buffer. There are three functions which handle
35       these and one "miscellaneous" function.
36
37       BUF_MEM_new() allocates a new buffer of zero size.
38
39       BUF_MEM_free() frees up an already existing buffer. The data is zeroed
40       before freeing up in case the buffer contains sensitive data.
41
42       BUF_MEM_grow() changes the size of an already existing buffer to len.
43       Any data already in the buffer is preserved if it increases in size.
44
45       BUF_strdup() copies a null terminated string into a block of allocated
46       memory and returns a pointer to the allocated block.  Unlike the
47       standard C library strdup() this function uses OPENSSL_malloc() and so
48       should be used in preference to the standard library strdup() because
49       it can be used for memory leak checking or replacing the malloc()
50       function.
51
52       The memory allocated from BUF_strdup() should be freed up using the
53       OPENSSL_free() function.
54

RETURN VALUES

56       BUF_MEM_new() returns the buffer or NULL on error.
57
58       BUF_MEM_free() has no return value.
59
60       BUF_MEM_grow() returns zero on error or the new size (i.e. len).
61

SEE ALSO

63       bio(3)
64

HISTORY

66       BUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all
67       versions of SSLeay and OpenSSL. BUF_strdup() was added in SSLeay 0.8.
68
69
70
711.0.1e                            2013-02-11                         buffer(3)
Impressum