mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-01-03 19:27:10 +00:00
[common] vector: implement a clear operation
This commit is contained in:
parent
b71838a530
commit
07d3d6cbe7
2 changed files with 6 additions and 0 deletions
|
@ -40,6 +40,7 @@ size_t vector_size(Vector * vector);
|
||||||
void * vector_data(Vector * vector);
|
void * vector_data(Vector * vector);
|
||||||
void vector_at(Vector * vector, size_t index, void * data);
|
void vector_at(Vector * vector, size_t index, void * data);
|
||||||
void * vector_ptrTo(Vector * vector, size_t index);
|
void * vector_ptrTo(Vector * vector, size_t index);
|
||||||
|
void vector_clear(Vector * vector);
|
||||||
|
|
||||||
#define vector_forEach(name, vector) \
|
#define vector_forEach(name, vector) \
|
||||||
for (char * vecIterCurrent = (vector)->data, \
|
for (char * vecIterCurrent = (vector)->data, \
|
||||||
|
|
|
@ -101,3 +101,8 @@ void * vector_ptrTo(Vector * vector, size_t index)
|
||||||
DEBUG_ASSERT(index < vector->size && "Out of bounds access");
|
DEBUG_ASSERT(index < vector->size && "Out of bounds access");
|
||||||
return (char *)vector->data + index * vector->itemSize;
|
return (char *)vector->data + index * vector->itemSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vector_clear(Vector * vector)
|
||||||
|
{
|
||||||
|
vector->size = 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue