vt_init_elem 7 2016-02-28 genvector manual

NAME

vt_init_elem - optional element initialization callback

SYNPOSIS

#define GVT_INIT_ELEM_FUNC

void (*init_elem)(GVTTYPE *vect, GVT_ELEM_TYPE *elem);

DESCRIPTION

When macro GVT_INIT_ELEM_FUNC is defined during vt_instantiation(7), genvector adds an init_elem callback function field to the vector structure. The caller should fill in this function pointer before or after the vector initialization.

Whenever a new element enters the vector, if init_elem is enabled and is not NULL, it is called on the element.

The purpose of this feature is to provide a simple mechanism through which the user can set the initial value of new/uninitialized elements in a flexible way (e.g. UUID field in a struct element).

While this mechanism works together with vt_construction(7), they are usually not enabled in the same time.

A much simpler alternative is vt_set_new_bytes_to(7).

SEE ALSO

vt_init_elem 7 2016-02-28 genvector manual