vt_get 3 2016-02-28 genvector manual

NAME

vt_get - return a pointer to an element

SYNPOSIS

vt_elem_t *vt_get(vt_t *vect, vt_size_t idx, int alloc)

DESCRIPTION

vt_get attempts to return a pointer to the element addressed by idx. If the element doesn't exist and alloc is non-zero, it is created (among with all other elements between the new element and the original vector end) and the pointer to the new element is returned. When creating new element(s), the usual initialization and/or construction scheme is in place.

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

Arguments:
vect A vector already initialized using vt_init.
idx The index of the element to be returned.
alloc Whether new element(s) should be allocated if idx is beyond the end of the vector.

RETURN VALUE

Returns the pointer to the element addressed, if the element exists or if alloc allowed it to be created. Else return NULL and leave the vector unchanged.

SEE ALSO

vt_get 3 2016-02-28 genvector manual