summaryrefslogtreecommitdiffstats
path: root/jv_parse.c
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2012-12-18 16:52:47 +0000
committerStephen Dolan <mu@netsoc.tcd.ie>2012-12-18 16:53:51 +0000
commit04daafbde36ab696069a9df17ff85629574491c4 (patch)
tree66bff8def53de1a0f27038d880bd1306dc2ced39 /jv_parse.c
parent75421cbfe32ae6428fe08b6ba83f1f7ac0322c33 (diff)
Add wrappers for malloc/realloc/free. See #43.
Diffstat (limited to 'jv_parse.c')
-rw-r--r--jv_parse.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/jv_parse.c b/jv_parse.c
index 738beb94..0d4f1549 100644
--- a/jv_parse.c
+++ b/jv_parse.c
@@ -5,6 +5,7 @@
#include "jv_dtoa.h"
#include "jv_parse.h"
#include "jv_unicode.h"
+#include "jv_alloc.h"
typedef const char* presult;
@@ -32,8 +33,8 @@ void jv_parser_free(struct jv_parser* p) {
jv_free(p->next);
for (int i=0; i<p->stackpos; i++)
jv_free(p->stack[i]);
- free(p->stack);
- free(p->tokenbuf);
+ jv_mem_free(p->stack);
+ jv_mem_free(p->tokenbuf);
jvp_dtoa_context_free(&p->dtoa);
}
@@ -48,7 +49,7 @@ static void push(struct jv_parser* p, jv v) {
assert(p->stackpos <= p->stacklen);
if (p->stackpos == p->stacklen) {
p->stacklen = p->stacklen * 2 + 10;
- p->stack = realloc(p->stack, p->stacklen * sizeof(jv));
+ p->stack = jv_mem_realloc(p->stack, p->stacklen * sizeof(jv));
}
assert(p->stackpos < p->stacklen);
p->stack[p->stackpos++] = v;
@@ -142,7 +143,7 @@ static void tokenadd(struct jv_parser* p, char c) {
assert(p->tokenpos <= p->tokenlen);
if (p->tokenpos == p->tokenlen) {
p->tokenlen = p->tokenlen*2 + 256;
- p->tokenbuf = realloc(p->tokenbuf, p->tokenlen);
+ p->tokenbuf = jv_mem_realloc(p->tokenbuf, p->tokenlen);
}
assert(p->tokenpos < p->tokenlen);
p->tokenbuf[p->tokenpos++] = c;