CBgetalloc — get the field value from buffer and copy it to newly allocated space, converted to user type
#include <ubf.h>
char * CBgetalloc (UBFH *p_ub, BFLDID bfldid, BFLDOCC occ, int usrtype, BFLDLEN *extralen);
Link with -lubf -lnstd -lm -lpthread
Get the field bfldid at occ occurrence from p_ub buffer. The value is converted to usrtype. The value is returned (copied to) to memory block allocated by function. There is extra parameter extralen. On input it indicates the additional space that shall be allocated. The extralen can be NULL, in that case no extra memory is allocated.
Function is based on Bgetalloc(3), which does not convert to user type, but returns direct value.
Function operations on field types BFLD_UBF and BFLD_VIEW are not supported. This includes type of bfldid or usrtype having any unsupported field types for this function.
On success, CBgetalloc() return zero; on error, -1 is returned, with Berror set to indicate the error.
Note that Bstrerror() returns generic error message plus custom message with debug info from last function call.
BALIGNERR Corrupted buffer or pointing to not aligned memory area.
BNOTFLD Buffer not fielded, not correctly allocated or corrupted.
BNOTPRES Field not present.
BMALLOC Failed to allocate type conversion buffer.
BBADFLD Invalid field passed to bfldid.
BTYPERR Invalid user type specified.
BEBADOP Operation not supported (e.g. work with BFLD_UBF or BFLD_VIEW type fields).