Add explicit casting for array capacities

This commit is contained in:
Matt 2022-09-21 15:48:23 -04:00
parent 70cfc55e58
commit 8751fa0853
No known key found for this signature in database
GPG key ID: CC209CE203F23602
3 changed files with 8 additions and 8 deletions

View file

@ -154,7 +154,7 @@ static inline void array__reserve(VoidArray *self, size_t element_size, uint32_t
} else {
self->contents = ts_malloc(new_capacity * element_size);
}
self->capacity = new_capacity;
self->capacity = (uint32_t)new_capacity;
}
}
@ -170,10 +170,10 @@ static inline void array__swap(VoidArray *self, VoidArray *other) {
*self = swap;
}
static inline void array__grow(VoidArray *self, size_t count, size_t element_size) {
size_t new_size = self->size + count;
static inline void array__grow(VoidArray *self, uint32_t count, size_t element_size) {
uint32_t new_size = self->size + count;
if (new_size > self->capacity) {
size_t new_capacity = self->capacity * 2;
uint32_t new_capacity = self->capacity * 2;
if (new_capacity < 8) new_capacity = 8;
if (new_capacity < new_size) new_capacity = new_size;
array__reserve(self, element_size, new_capacity);