vt_set 3 2016-02-28 genvector manual


vt_set - ovrewrite an element


int vt_set(vt_t *vect, vt_size_t idx, vt_elem_t src)


vt_set overwrites the content of the element addressed by idx using data from src. If idx is beyond the length of the vector, the vector is enlarged. If the vector has an user defined copy function, it is used for the copy - the destination is uninitialized and is not constructed before the call. When creating new element(s), the usual initialization and/or construction scheme is in place, but the element at address idx is not constructed before it is overwritten (user copy function is assumed to do the construction).

If there's a destructor defined, the old vector element at idx is destructed before it is overwritten.

Note: vt_t and the vt_ prefix are type-dependant, see vt_t(7).

vect A vector already initialized using vt_init.
idx The index of the element to be overwritten.
src Data which the addressed element is overwritten with. NOTE: src is NOT passed as a reference; when src is a struct, consider using vt_set_ptr instead.


Returns 0 on success, -1 on failure. Error conditions include memory allocation or user supplied elem copy function failure.


vt_set 3 2016-02-28 genvector manual