2023-11-23 18:02:40 +00:00
|
|
|
#ifndef _BOOTSTRAP_DYN_ARRAY_H
|
|
|
|
#define _BOOTSTRAP_DYN_ARRAY_H
|
2023-11-22 20:43:34 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2023-11-22 21:39:27 +00:00
|
|
|
struct DynArray {
|
|
|
|
void **buf;
|
|
|
|
// The size of @buf excluding `NUL`.
|
|
|
|
size_t size;
|
|
|
|
// The allocated size of @buf including `NUL`.
|
|
|
|
size_t _capacity;
|
|
|
|
};
|
2023-11-22 20:43:34 +00:00
|
|
|
|
|
|
|
struct DynArray *dyn_array_new(size_t capacity);
|
|
|
|
|
|
|
|
size_t dyn_array_size(struct DynArray *a);
|
|
|
|
|
|
|
|
void dyn_array_push(struct DynArray *a, void *item);
|
|
|
|
|
|
|
|
void dyn_array_free(struct DynArray *a);
|
|
|
|
|
2023-11-23 18:02:40 +00:00
|
|
|
#endif /* _BOOTSTRAP_DYN_ARRAY_H */
|