Skip to content

Commit

Permalink
Add 'cowl_vector_reserve'
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanoBilenchi committed Jan 7, 2025
1 parent f1d7586 commit f95d1cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ulib
4 changes: 4 additions & 0 deletions src/cowl_vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ bool cowl_vector_iterate_primitives(CowlVector *vec, CowlPrimitiveFlags flags, C
return true;
}

cowl_ret cowl_vector_reserve(CowlVector *vec, ulib_uint capacity) {
return uvec_reserve(CowlObjectPtr, &vec->data, capacity) ? COWL_ERR_MEM : COWL_OK;
}

cowl_ret cowl_vector_add(CowlVector *vec, CowlAny *object) {
if (uvec_push(CowlObjectPtr, &vec->data, object)) return COWL_ERR_MEM;
cowl_retain(object);
Expand Down
1 change: 1 addition & 0 deletions src/cowl_vector_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct CowlVector {
CowlVector *cowl_vector_ordered_empty(void);
void cowl_vector_free(CowlVector *vec);
void cowl_vector_release_ex(CowlVector *vec, bool release_elements);
cowl_ret cowl_vector_reserve(CowlVector *vec, ulib_uint capacity);
cowl_ret cowl_vector_add(CowlVector *vec, CowlAny *object);
cowl_ret cowl_vector_push(CowlVector *vec, CowlAny *object);
bool cowl_vector_remove(CowlVector *vec, CowlAny *object);
Expand Down

0 comments on commit f95d1cd

Please sign in to comment.