34 a->data = calloc(
sz, initial_num);
41 a->allocated = initial_num;
48static inline void *fpm_array_item(
struct fpm_array_s *
a,
unsigned int n)
52 ret = (
char *)
a->data +
a->sz *
n;
58static inline void *fpm_array_item_last(
struct fpm_array_s *
a)
60 return fpm_array_item(
a,
a->used - 1);
64static inline int fpm_array_item_remove(
struct fpm_array_s *
a,
unsigned int n)
69 void *
last = fpm_array_item(
a,
a->used - 1);
70 void *to_remove = fpm_array_item(
a,
n);
87 if (
a->used ==
a->allocated) {
88 size_t new_allocated =
a->allocated ?
a->allocated * 2 : 20;
96 a->allocated = new_allocated;
99 ret = fpm_array_item(
a,
a->used);
112 a->used =
a->allocated = 0;
#define safe_perealloc(ptr, nmemb, size, offset, persistent)