forked from vieter-v/libvieter
37 lines
750 B
C
37 lines
750 B
C
#ifndef VIETER_DYNARRAY
|
|
#define VIETER_DYNARRAY
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "vieter_package.h"
|
|
|
|
typedef struct dynarray dynarray;
|
|
struct dynarray {
|
|
char **array;
|
|
size_t capacity;
|
|
size_t size;
|
|
};
|
|
|
|
/*
|
|
* Allocate a dynamic array.
|
|
*/
|
|
dynarray *vieter_package_dynarray_init(size_t initial_capacity);
|
|
|
|
/*
|
|
* Initialise array (if it's not already initialised) and insert a string.
|
|
*/
|
|
void vieter_package_dynarray_add(dynarray *da, const char * s);
|
|
|
|
/*
|
|
* Deallocate dynamic array.
|
|
*/
|
|
void vieter_package_dynarray_free(dynarray *da);
|
|
|
|
/*
|
|
* Convert a dynarray into an array by freeing all its surrounding components
|
|
* and returning the underlying array pointer.
|
|
*/
|
|
char **vieter_package_dynarray_convert(dynarray *da);
|
|
|
|
#endif
|