Previous: Header Field Creation and Deletion, Up: Manipulating Header Fields
Header fields are resized with the bpipe_hdrf_resize
routine.
Unlike data fields, which are resized upon input or output of a data
packet, header fields are resized immediately. After a resize, any
previous matrix-spec or data pointers (obtained with
bpipe_hdrf_data
) are invalid and must be retrieved again. (Note
that since the BPMatrix
structure returned by
bpipe_hdrf_matrix
is a copy of the field's
matrix-spec, the application has the responsibility of freeing
it.)
Resizing a field consists of specifying three pieces of information:
bpipe_hdrf_matrix
and
tweak the extents array:
BPMatrix *matrix = bpipe_hdrf_matrix( field-name, field-index ); if (NULL == matrix) { (error handling code) } matrix->extent[0]++;
This is also a good approach when changing a field's dimension:
BPMatrix *matrix = bpipe_hdrf_matrix( field-name, field-index ); if (NULL == matrix) { (error handling code) } /* increment the number of dimensions and reallocate the extent array */ matrix->nd++; matrix->extent = (size_t *) realloc( matrix->extent, matrix->nd * sizeof(size_t) ); if (NULL == matrix->extent) { (error handling code) } matrix->extent[matrix->nd - 1] = 2;
More general changes should be done by creating a new matrix-spec
via bpipe_matrix_new
or bpipe_matrix_new
.
size_t
, and can easily be created by one of the utility
routines (bpipe_extent_new
, bpipe_extent_new_va
,
bpipe_offset_new
and bpipe_offset_new_va
). The
destination offset is also a one dimensional size_t
array.
See bpipe_hdrf_resize.