vector_get

NAME
SYNOPSIS
DESCRIPTION
AUTHOR
LICENSE
VERSION

NAME

vector_get, _vector_get, vector_get_ptr, _vector_get_ptr - array-style indexing for vectors

SYNOPSIS

#include <vector.h>

#define vector_get(v,i,obj) _vector_get((v),(i),&(obj))
void _vector_get (vector, int i, void *ptr);
#define vector_get_ptr(v,i,ptr) (ptr) =((typeof (ptr))_vector_get_ptr((v),(i)))
const void *_vector_get_ptr (vector, int i);

DESCRIPTION

vector_get copies the element at index v[i] into local variable obj. The vector is unaffected.
_vector_get copies the element into the memory pointed to by ptr. If ptr is NULL then the effect is simply to check that element v[i] exists.
vector_get_ptr and _vector_get_ptr are used to get a pointer to an element in the vector. This pointer actually points to the vector's internal data array. It is only valid as long as the user does not cause the internal data array to be reallocated or moved - typically this can happen when the user performs some operation which inserts more elements into the array.
Array indexes are checked. An attempt to access an out-of-bounds element will result in a call to abort(3).

AUTHOR

Richard Jones <rich@annexia.org>

LICENSE

GNU LGPL (see http://www.gnu.org/)

VERSION

c2lib-1.2.13