25 lines
509 B
C
25 lines
509 B
C
#ifndef VIETER_DYNARRAY
|
|
#define VIETER_DYNARRAY
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
typedef struct dyn_array DynArray;
|
|
struct dyn_array {
|
|
char **array;
|
|
size_t capacity;
|
|
size_t size;
|
|
};
|
|
|
|
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
|