Add wrappers for malloc/realloc/free. See #43.

This commit is contained in:
Stephen Dolan committed 2012-12-18 16:53:51 +00:00
1 parent 75421cbfe3
commit 04daafbde3
15 files changed
+106 -51

No files matched your search

+3 -2
View File
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#include "jv_alloc.h"
typedef struct {
int start, end;
} location;
@@ -24,7 +25,7 @@ static void locfile_init(struct locfile* l, const char* data, int length) {
for (int i=0; i<length; i++) {
if (data[i] == '\n') l->nlines++;
}
l->linemap = malloc(sizeof(int) * (l->nlines + 1));
l->linemap = jv_mem_alloc(sizeof(int) * (l->nlines + 1));
l->linemap[0] = 0;
int line = 1;
for (int i=0; i<length; i++) {
@@ -37,7 +38,7 @@ static void locfile_init(struct locfile* l, const char* data, int length) {
}
static void locfile_free(struct locfile* l) {
free(l->linemap);
jv_mem_free(l->linemap);
}
static int locfile_get_line(struct locfile* l, int pos) {