27#define GP_VEC(ptr) (GP_CONTAINER_OF(ptr, gp_vec, payload))
118 return GP_VEC(self)->length;
134 return GP_VEC(self)->unit;
234#define GP_VEC_FOREACH(self, type, iterator) \
235 for (type *iterator = (self); iterator < (self) + gp_vec_len(self); iterator++)
244#define GP_VEC_APPEND(vec, val) ({ \
245 typeof(vec) gp_ret__ = gp_vec_expand(vec, 1); \
247 gp_ret__[gp_vec_len(gp_ret__)-1] = val; \
A compiler dependent macros.
#define GP_WUR
Expands to warn_unused_result attribute when supported by the compiler.
void * gp_vec_shrink(void *self, size_t len)
Shrinks vector by length elements at the end of the vector.
#define GP_VEC(ptr)
Converts a vector pointer into the header i.e. struct gp_vec.
void * gp_vec_resize(void *self, size_t len)
Resize vector.
gp_vec * gp_vec_shrink_(gp_vec *self, size_t len)
Shrinks vector length; does not touch vector data.
void * gp_vec_expand(void *self, size_t len)
Expands vector by length elements at the end of the vector.
void * gp_vec_dup(void *self)
Creates a duplicate of a vector.
static size_t gp_vec_len(const void *self)
Returns vector lenght.
void * gp_vec_del(void *self, size_t off, size_t len)
Deletes a range from the vector.
static size_t gp_vec_unit(const void *self)
Returns vector unit.
void * gp_vec_move_shrink(void *self, size_t idx)
Moves last object in vector to idx and shrinks the vector by one.
void * gp_vec_new(size_t len, size_t unit)
Allocates a new vector.
void * gp_vec_ins(void *self, size_t off, size_t len)
Insert a gap into the vec of new elements, reallocating the underlying memory if more capacity is nee...
gp_vec * gp_vec_expand_(gp_vec *self, size_t len)
Expands vector length; does not touch vector data.
void gp_vec_free(void *self)
Frees the vector.