refactor dynamic array API: rename builder functions, update memory management, and improve tests
This commit is contained in:
@@ -5,24 +5,29 @@
|
||||
|
||||
typedef struct Array {
|
||||
int *value;
|
||||
int size;
|
||||
int capacity;
|
||||
} Array;
|
||||
|
||||
|
||||
typedef struct ArrayBuilderOptions {
|
||||
typedef struct ArrayCreateOptions {
|
||||
int initial_size;
|
||||
} ArrayBuilderOptions;
|
||||
|
||||
Array *array_builder(const ArrayBuilderOptions *options);
|
||||
} ArrayCreateOptions;
|
||||
|
||||
|
||||
void array_deconstructor(Array *array);
|
||||
#define DEFAULT_ARRAY_CREATE_OPTIONS \
|
||||
(ArrayCreateOptions){ DEFAULT_ARRAY_SIZE }
|
||||
|
||||
Array *array_create(const ArrayCreateOptions *options);
|
||||
|
||||
|
||||
void array_resize(Array *array, int new_size);
|
||||
void array_deconstructor(Array **pp_array);
|
||||
|
||||
|
||||
int *array_get_value(const Array *array, int index);
|
||||
void array_resize(Array *p_array, int new_size);
|
||||
|
||||
|
||||
void array_set_value(Array *array, int index, int value);
|
||||
int *array_get_value(const Array *p_array, int index);
|
||||
|
||||
|
||||
void array_set_value(Array *p_array, int index, int value);
|
||||
Reference in New Issue
Block a user