1=pod 2 3=head1 NAME 4 5BUF_MEM_new, BUF_MEM_free, BUF_MEM_grow, BUF_strdup - simple 6character 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 22The buffer library handles simple character arrays. Buffers are used for 23various purposes in the library, most notably memory BIOs. 24 25The 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 34B<length> is the current size of the buffer in bytes, B<max> is the amount of 35memory allocated to the buffer. There are three functions which handle these 36and one "miscellaneous" function. 37 38BUF_MEM_new() allocates a new buffer of zero size. 39 40BUF_MEM_free() frees up an already existing buffer. The data is zeroed 41before freeing up in case the buffer contains sensitive data. 42 43BUF_MEM_grow() changes the size of an already existing buffer to 44B<len>. Any data already in the buffer is preserved if it increases in 45size. 46 47BUF_strdup() copies a null terminated string into a block of allocated 48memory and returns a pointer to the allocated block. 49Unlike the standard C library strdup() this function uses OPENSSL_malloc() and so 50should be used in preference to the standard library strdup() because it can 51be used for memory leak checking or replacing the malloc() function. 52 53The memory allocated from BUF_strdup() should be freed up using the OPENSSL_free() 54function. 55 56=head1 RETURN VALUES 57 58BUF_MEM_new() returns the buffer or NULL on error. 59 60BUF_MEM_free() has no return value. 61 62BUF_MEM_grow() returns zero on error or the new size (i.e. B<len>). 63 64=head1 SEE ALSO 65 66L<bio(3)|bio(3)> 67 68=head1 HISTORY 69 70BUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all 71versions of SSLeay and OpenSSL. BUF_strdup() was added in SSLeay 0.8. 72 73=cut 74