Make stack popping more robust
This commit is contained in:
parent
64874449e4
commit
c88e9044d5
6 changed files with 328 additions and 151 deletions
|
|
@ -25,11 +25,20 @@ static inline Vector vector_new(size_t element_size, size_t capacity) {
|
|||
};
|
||||
}
|
||||
|
||||
static inline void vector_delete(Vector *self) {
|
||||
free(self->contents);
|
||||
}
|
||||
|
||||
static inline void *vector_get(Vector *self, size_t index) {
|
||||
assert(index < self->size);
|
||||
return (void *)((char *)self->contents + index * self->element_size);
|
||||
}
|
||||
|
||||
static inline void *vector_back(Vector *self) {
|
||||
assert(self->size > 0);
|
||||
return vector_get(self, self->size - 1);
|
||||
}
|
||||
|
||||
static inline void vector_clear(Vector *self) {
|
||||
self->size = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue