Next: , Previous: bpipe_map, Up: BPipe Manipulations


A.1.4 bpipe_map_alloc

create transformation maps for data packet fields and allocate data packets

Synopsis

     #include <bpipe/bpipe.h>
     
     
     
void *bpipe_map_alloc( BPipe *bpipe, int ndpkts, size_t *size_p );

Parameters

BPipe *bpipe
a pointer to a binary pipe structure
int ndpkts
the number of data packets to allocate
size_t *size_p
if not ‘NULL’, a location where the size of the data packet will be stored

Description

bpipe_map_alloc is a convenience routine that calls bpipe_map to map the data packet, then allocates space for the requested number of data packets. The space allocated is managed by BPipe; the calling program should not free it. If the parameter size_p is not ‘NULL’, it should point to an integer where the size of the data packet will be stored.

This routine should only be called once. It will not re-map an already mapped BPipe.

Returns

It returns a pointer to the allocated space upon sucess. Upon error it returns ‘NULL’ and sets bpipe_errno.

Errors

Upon error bpipe_errno is set to one of the following:

BPEBADARG

BPEBADPIPE
either all of the input data packet fields were deleted or all of an output channel's data packet fields were deleted.
BPENOMEM
a memory allocation failed