#ifndef _BARRAY_H #define _BARRAY_H #include #include typedef struct { void* ptr; size_t len; size_t cap; size_t elem_size; } BArray; typedef enum { BARRAY_NO_ERR, BARRAY_ERR_ALLOC_ERR, BARRAY_ERR_OUT_OF_BOUNDS, BARRAY_ERR_SIZE_OVERFLOW, BARRAY_ERR_NULL, BARRAY_ERR_ELEM_SIZE_ZERO } BArray_ErrCode; BArray barray_create(size_t elem_size, size_t initial_cap, BArray_ErrCode* errc); void barray_grow(BArray* array, BArray_ErrCode* errc); void barray_grow_to(BArray* array, size_t new_cap, BArray_ErrCode* errc); void barray_shrink_to_fit(BArray* array, BArray_ErrCode* errc); void barray_force_shrink(BArray* array, size_t new_cap, BArray_ErrCode* errc); void* barray_get(BArray* array, size_t ix, BArray_ErrCode* errc); void barray_set(BArray* array, size_t ix, void* value, BArray_ErrCode* errc); void barray_put(BArray* array, size_t ix, void* value, BArray_ErrCode* errc); void barray_append(BArray* array, void* value, BArray_ErrCode* errc); void* barray_put_uninitialized(BArray* array, size_t ix, BArray_ErrCode* errc); void barray_remove(BArray* array, size_t ix, BArray_ErrCode* errc); void barray_clear(BArray* array, BArray_ErrCode* errc); void barray_destroy(BArray* array, BArray_ErrCode* errc); #endif /* _BARRAY_H */