vt_truncate 3 2016-02-28 genvector manual

NAME

vt_truncate - shrink a vector to the size specified

SYNPOSIS

int vt_truncate(vt_t *vect, vt_size_t new_size)

DESCRIPTION

vt_truncate calls vt_resize for shrink and adjusts the used field (aka the length of the vector). For terminated vectors, the terminator is also updated. If new_size is larger than the current size of the vector, no resize is performed and an error is returned.

If new_size is 0, a terminated vector is resized to its minimal allocation, length set to 0 and the terminator written in the 0th record; the array field of an unterminated vector is free'd and set to NULL.

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

Arguments:
vect A vector already initialized using vt_init.
new_size The new size of the vector (should be smaller than current length).

RETURN VALUE

Returns 0 on success or -1 on error. Error conditions include new size being larger than current size.

SEE ALSO

vt_truncate 3 2016-02-28 genvector manual