From 5e2691460e9fb2ec9b77c1f9d133ae6b667afc3a Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sun, 28 Jun 2009 15:41:53 -0700 Subject: Ditch abbreviated field business. --- upb_parse.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'upb_parse.c') diff --git a/upb_parse.c b/upb_parse.c index 2b9c875..57cca2b 100644 --- a/upb_parse.c +++ b/upb_parse.c @@ -8,6 +8,7 @@ #include #include +#include #include #include "descriptor.h" @@ -266,6 +267,22 @@ upb_status_t upb_parse_value(void **b, upb_field_type_t ft, #undef CASE } +void upb_parse_state_init(struct upb_parse_state *state, size_t udata_size) +{ + state->offset = 0; + size_t stack_bytes = (sizeof(*state->stack) + udata_size) * UPB_MAX_NESTING; + state->stack = state->top = malloc(stack_bytes); + state->limit = (struct upb_parse_stack_frame*)((char*)state->stack + stack_bytes); + state->udata_size = udata_size; + state->done = false; + state->packed_end_offset = 0; +} + +void upb_parse_state_free(struct upb_parse_state *state) +{ + free(state->stack); +} + static void pop_stack_frame(struct upb_parse_state *s) { s->submsg_end_cb(s); -- cgit v1.2.3