diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-12-18 16:52:47 +0000 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-12-18 16:53:51 +0000 |
commit | 04daafbde36ab696069a9df17ff85629574491c4 (patch) | |
tree | 66bff8def53de1a0f27038d880bd1306dc2ced39 /jv_parse.c | |
parent | 75421cbfe32ae6428fe08b6ba83f1f7ac0322c33 (diff) |
Add wrappers for malloc/realloc/free. See #43.
Diffstat (limited to 'jv_parse.c')
-rw-r--r-- | jv_parse.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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; |