Start work on removing parent pointers
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
This commit is contained in:
parent
8300f24fec
commit
973e4a44f0
14 changed files with 410 additions and 324 deletions
|
|
@ -58,6 +58,9 @@ extern "C" {
|
|||
|
||||
#define array_pop(self) ((self)->contents[--(self)->size])
|
||||
|
||||
#define array_assign(self, other) \
|
||||
array__assign((VoidArray *)(self), (const VoidArray *)(other), array__elem_size(self))
|
||||
|
||||
// Private
|
||||
|
||||
typedef Array(void) VoidArray;
|
||||
|
|
@ -91,6 +94,12 @@ static inline void array__reserve(VoidArray *self, size_t element_size, uint32_t
|
|||
}
|
||||
}
|
||||
|
||||
static inline void array__assign(VoidArray *self, const VoidArray *other, size_t element_size) {
|
||||
array__reserve(self, element_size, other->size);
|
||||
self->size = other->size;
|
||||
memcpy(self->contents, other->contents, self->size * element_size);
|
||||
}
|
||||
|
||||
static inline void array__grow(VoidArray *self, size_t element_size) {
|
||||
if (self->size == self->capacity) {
|
||||
size_t new_capacity = self->capacity * 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue