User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v7.5.x:api:ubf:baddfast.3

baddfast

Name

Baddfast — Fast adding to buffer

Synopsis

#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

DESCRIPTION

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. Function is beneficial for carray or string fields, as on these types UBF does not perform binary search to get the position.

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 field type is BFLD_CARRAY. The data type for buf must match with bfldid type.

RETURN VALUE

On success, Baddfast() return zero; on error, -1 is returned, with Berror set to indicate the error.

ERRORS

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.

EXAMPLE

See ubftest/test_badd.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd