Compare commits

...

No commits in common. 'b7967a5d5ec202d92af34cdc9083bcef873eca7a' and '143a64f7de7857209716c0379849698fb7b3b6bd' have entirely different histories.

  1. 3
      README.md
  2. 1
      include/barray.h
  3. 12
      src/barray.c

@ -0,0 +1,3 @@
# barray
This is a tiny library containing a dynamic array implementation

@ -31,4 +31,5 @@ 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_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 */

@ -271,3 +271,15 @@ void barray_clear(BArray *array, BArray_ErrCode *errc) {
*errc = BARRAY_NO_ERR;
array->len = 0;
}
void barray_destroy(BArray *array, BArray_ErrCode* errc) {
assert(errc != NULL);
if (array == NULL) {
*errc = BARRAY_ERR_NULL;
}
if (array->ptr != NULL) {
free(array->ptr);
}
*errc = BARRAY_NO_ERR;
*array = BARRAY_INVALID;
}

Loading…
Cancel
Save