Previous: Manipulating Header Fields, Up: Accessing the data stream


4.4 Manipulating Data Packet Fields

The manipulation of data packet fields is a bit trickier than that of header fields. As mentioned previously, data fields are mapped between input, core, and output states, and can be resized or deleted separately in more than one state. Because of this, information about a data packet field (such as where the actual data is located) is not available until all of the sizing, additions, and deletions have been finalized. The core and output images of a data packet are constructed by calling bpipe_map or bpipe_map_alloc. It is only after this call that an application can request information about the position of particular fields within a data packet.

Additionally, memory for the data packet has to be allocated; usually this is done with the bpipe_map_alloc command. This memory will be freed when the bpipe is closed. If for some reason (double buffering of photons at the program level, for instance) the program is to handle allocation and deallocation, then bpipe_map should be used. It does not allocate space, but returns the size of a data packet. The application is then responsible for all allocation and deallocation.