Table of Contents
#include <ubf.h>
int Baddfast (UBFH *p_ub, BFLDID bfldid, char *buf, BFLDLEN len, Bfld_loc_info_t *next_fld);
Link with -lubf -lnstd -lm -lpthread
Add field to UBF buffer. By difference to Badd, this function offers to add next occurrence of the field just right after the previous Baddfast function. So basically if batch of occurrences needs to be loaded to buffer or incrementing BFLDID of the same type needs to be added to the buffer in quick manner, then at first call provide next_fld set to 0 (memset(next_fld, 0, sizeof(next_fld))). Then first call will add data as normal Badd() call, but in result next_fld will keep the pointer to last position of the buffer, just right after data inserted. Thus Next Baddfast() is performing from that place. The benefit is avoided position search in buffer, which at large number of occurrences might grow exponentially. Then p_ub buffer must not be modified between the calls. next_fld is valid only for adding the same field occurrences or adding (when programmer knows for sure), incremented field id. In that case search can be avoided too. That can be beneficial in case if adding carrays or strings, as on the UBF does not do binary search.
The UBF buffer pointer is passed by p_ub, field id in bfldid. The user value is passed in buf. The len is used only if filed type is BFLD_CARRAY, for which length cannot be detected from passed data. The data type for buf must batch with bfldid type.
On success, Baddfast() 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.
BEINVAL next_fld is NULL
BALIGNERR Corrupted buffer or pointing to not aligned memory area.
BNOTFLD Buffer not fielded, not correctly allocated or corrupted.
BNOSPACE No space in buffer for string data.
Report bugs to support@mavimax.com