[common] vector: implement a clear operation

This commit is contained in:
Quantum 2021-08-22 07:47:40 -04:00 committed by Geoffrey McRae
parent b71838a530
commit 07d3d6cbe7
2 changed files with 6 additions and 0 deletions

View File

@ -40,6 +40,7 @@ size_t vector_size(Vector * vector);
void * vector_data(Vector * vector);
void vector_at(Vector * vector, size_t index, void * data);
void * vector_ptrTo(Vector * vector, size_t index);
void vector_clear(Vector * vector);
#define vector_forEach(name, vector) \
for (char * vecIterCurrent = (vector)->data, \

View File

@ -101,3 +101,8 @@ void * vector_ptrTo(Vector * vector, size_t index)
DEBUG_ASSERT(index < vector->size && "Out of bounds access");
return (char *)vector->data + index * vector->itemSize;
}
void vector_clear(Vector * vector)
{
vector->size = 0;
}