2023-01-25 13:00:33 +01:00
|
|
|
#ifndef VIETER_DYNARRAY
|
|
|
|
#define VIETER_DYNARRAY
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
typedef struct dyn_array DynArray;
|
2023-01-25 17:24:03 +01:00
|
|
|
struct dyn_array {
|
|
|
|
char **array;
|
|
|
|
size_t capacity;
|
|
|
|
size_t size;
|
|
|
|
};
|
2023-01-25 13:00:33 +01:00
|
|
|
|
|
|
|
DynArray *dynarray_init(size_t initial_capacity);
|
|
|
|
void dynarray_add(DynArray *da, const char * s);
|
|
|
|
void dynarray_free(DynArray *da);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a DynArray into an array by freeing all its surrounding components
|
|
|
|
* and returning the underlying array pointer.
|
|
|
|
*/
|
|
|
|
char **dynarray_convert(DynArray *da);
|
|
|
|
|
|
|
|
#endif
|