Next: bpipe_datatype_init, Previous: bpipe_data_copy, Up: Utility Functions
allocate memory for and duplicate a contiguous list of objects
#include <bpipe/bpipe.h>void *bpipe_data_dup( void *data, size_t n, size_t size, int create_empty );
void *data
- the buffer containing the data
size_t n
- the number of elements of data
size_t size
- the size of an element
int create_empty
- if true, allocate and clear memory if the parameter data is NULL
bpipe_data_dup
allocates a block of memory and copies a
sequential list of objects to that memory. If the pointer to the
original data is NULL
, and the create_empty
flag is
non zero, a block of memory large enough to contain the specified
data is created and cleared. If the flag is zero, NULL
is
returned.
It returns a pointer to a block of memory duplicating the original
data. Upon error bpipe_errno
is set and NULL
is
returned.
Upon error bpipe_errno
is set to one of the following errors:
BPENOMEM