Mercurial > ~dholland > hg > ag > index.cgi
view help2html/array.h @ 5:7661c1604e49
Add additional operator delete calls gcc 10 asked for.
author | David A. Holland |
---|---|
date | Mon, 30 May 2022 23:32:56 -0400 |
parents | 13d2b8934445 |
children | 60b08b68c750 |
line wrap: on
line source
#include <assert.h> /* treat as opaque */ struct array { void **v; unsigned num, max; }; struct array *array_create(void); void array_init(struct array *a); void array_cleanup(struct array *a); void array_destroy(struct array *a); unsigned array_num(const struct array *a); void *array_get(const struct array *a, unsigned ix); void array_set(struct array *a, unsigned ix, void *ptr); unsigned array_add(struct array *a, void *ptr); void array_setsize(struct array *a, unsigned newsize); /* compact, removing any null elements */ void array_nonulls(struct array *a); /* x and y are pointers that were placed in the array */ void array_sort(struct array *a, int (*f)(void *x, void *y)); extern inline unsigned array_num(const struct array *a) { return a->num; } extern inline void *array_get(const struct array *a, unsigned ix) { assert(ix < a->num); return a->v[ix]; } extern inline void array_set(struct array *a, unsigned ix, void *ptr) { assert(ix < a->num); a->v[ix] = ptr; }