[common] vector: allow inplace construction with vector_push

This makes vector_push return a pointer to the pushed element.

It also allows the user to push a NULL pointer, which means allocating the
memory for the element but do not copy anything into it.
This commit is contained in:
Quantum authored and Geoffrey McRae committed 2021-08-24 22:10:36 +10:00
1 parent 07d3d6cbe7
commit 53b4b4818b
2 files changed
+7 -5

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ Vector;
Vector * vector_create(size_t itemSize, size_t capacity);
void vector_free(Vector * vector);
bool vector_push(Vector * vector, void * item);
void * vector_push(Vector * vector, void * item);
void vector_pop(Vector * vector);
size_t vector_size(Vector * vector);
void * vector_data(Vector * vector);