diff options
Diffstat (limited to 'upb/json/parser.rl')
-rw-r--r-- | upb/json/parser.rl | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/upb/json/parser.rl b/upb/json/parser.rl index 3e1ea94..b67f08d 100644 --- a/upb/json/parser.rl +++ b/upb/json/parser.rl @@ -19,12 +19,11 @@ ** - handling of keys/escape-sequences/etc that span input buffers. */ -#include <stdio.h> -#include <stdint.h> #include <assert.h> -#include <string.h> -#include <stdlib.h> #include <errno.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> #include "upb/json/parser.h" @@ -1332,12 +1331,12 @@ static void free_json_parsermethod(upb_refcounted *r) { upb_value val = upb_inttable_iter_value(&i); upb_strtable *t = upb_value_getptr(val); upb_strtable_uninit(t); - free(t); + upb_gfree(t); } upb_inttable_uninit(&method->name_tables); - free(r); + upb_gfree(r); } static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) { @@ -1354,7 +1353,7 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) { } /* TODO(haberman): handle malloc failure. */ - t = malloc(sizeof(*t)); + t = upb_gmalloc(sizeof(*t)); upb_strtable_init(t, UPB_CTYPE_CONSTPTR); upb_inttable_insertptr(&m->name_tables, md, upb_value_ptr(t)); @@ -1367,7 +1366,7 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) { size_t field_len = upb_fielddef_getjsonname(f, buf, len); if (field_len > len) { size_t len2; - buf = realloc(buf, field_len); + buf = upb_grealloc(buf, 0, field_len); len = field_len; len2 = upb_fielddef_getjsonname(f, buf, len); UPB_ASSERT_VAR(len2, len == len2); @@ -1386,7 +1385,7 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) { } } - free(buf); + upb_gfree(buf); } /* Public API *****************************************************************/ @@ -1426,7 +1425,7 @@ upb_json_parsermethod *upb_json_parsermethod_new(const upb_msgdef* md, const void* owner) { static const struct upb_refcounted_vtbl vtbl = {visit_json_parsermethod, free_json_parsermethod}; - upb_json_parsermethod *ret = malloc(sizeof(*ret)); + upb_json_parsermethod *ret = upb_gmalloc(sizeof(*ret)); upb_refcounted_init(upb_json_parsermethod_upcast_mutable(ret), &vtbl, owner); ret->msg = md; |