mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 06:47:19 +00:00
[common] vector: assert if the vector itemSize <= 0
This commit is contained in:
parent
21cd380cad
commit
c591f7a8ae
@ -66,12 +66,15 @@ bool vector_create(Vector * vector, size_t itemSize, size_t capacity)
|
|||||||
void vector_destroy(Vector * vector)
|
void vector_destroy(Vector * vector)
|
||||||
{
|
{
|
||||||
free(vector->data);
|
free(vector->data);
|
||||||
|
vector->data = NULL;
|
||||||
vector->capacity = 0;
|
vector->capacity = 0;
|
||||||
vector->itemSize = 0;
|
vector->itemSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void * vector_push(Vector * vector, void * item)
|
void * vector_push(Vector * vector, void * item)
|
||||||
{
|
{
|
||||||
|
DEBUG_ASSERT(vector->itemSize > 0 && "itemSize should not be zero");
|
||||||
|
|
||||||
if (vector->size >= vector->capacity)
|
if (vector->size >= vector->capacity)
|
||||||
{
|
{
|
||||||
size_t newCapacity = vector->capacity < 4 ? 8 : vector->capacity * 2;
|
size_t newCapacity = vector->capacity < 4 ? 8 : vector->capacity * 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user