buffer(3) OpenSL buffer(3)
NAME
BUFMEMnew, BUFMEMfree, BUFMEMgrow, BUFstrdup - simple character
arrays structure
SYNOPSIS
#include
BUFMEM *BUFMEMnew(void);
void BUFMEMfree(BUFMEM *a);
int BUFMEMgrow(BUFMEM *str, int len);
char * BUFstrdup(const char *str);
DESCRIPTION
The buffer library handles simple character arrays. Buffers are used
for various purposes in the library, most notably memory BIOs.
The library uses the BUFMEM structure defined in buffer.h:
typedef struct bufmemst
{
int length; /* current number of bytes */
char *data;
int max; /* size of buffer */
} BUFMEM;
length is the current size of the buffer in bytes, max is the amount of
memory allocated to the buffer. There are three functions which handle
these and one "miscellaneous" function.
BUFMEMnew() allocates a new buffer of zero size.
BUFMEMfree() frees up an already existing buffer. The data is zeroed
before freeing up in case the buffer contains sensitive data.
BUFMEMgrow() changes the size of an already existing buffer to len.
Any data already in the buffer is preserved if it increases in size.
BUFstrdup() copies a null terminated string into a block of allocated
memory and returns a pointer to the allocated block. Unlike the stan-
dard C library strdup() this function uses OPENSLmalloc() and so
should be used in preference to the standard library strdup() because
it can be used for memory leak checking or replacing the malloc() func-
tion.
The memory allocated from BUFstrdup() should be freed up using the
OPENSLfree() function.
RETURN VALUES
BUFMEMnew() returns the buffer or NUL on error.
BUFMEMfree() has no return value.
BUFMEMgrow() returns zero on error or the new size (i.e. len).
SEE ALSO
bio(3)
HISTORY
BUFMEMnew(), BUFMEMfree() and BUFMEMgrow() are available in all
versions of SLeay and OpenSL. BUFstrdup() was added in SLeay 0.8.
0.9.7l 2000-09-19 buffer(3)
|