Fix leaked nodes in stack

This commit is contained in:
Max Brunsfeld 2016-01-28 21:18:57 -08:00
parent ca6dfb81d9
commit 5f27550a7a
3 changed files with 129 additions and 57 deletions

View file

@ -8,6 +8,7 @@ extern "C" {
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include "runtime/alloc.h"
typedef struct {
@ -37,7 +38,10 @@ static inline bool vector_valid(Vector *self) {
}
static inline void vector_delete(Vector *self) {
ts_free(self->contents);
if (self->contents) {
ts_free(self->contents);
self->contents = NULL;
}
}
static inline void *vector_get(Vector *self, size_t index) {