diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-06-28 15:41:53 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-06-28 15:41:53 -0700 |
commit | 5e2691460e9fb2ec9b77c1f9d133ae6b667afc3a (patch) | |
tree | f64dbba7d073ca6ee8b4c9e0c8ba77fa51a3b72d /upb_parse.c | |
parent | 03616c86ea3ba2d8da1e5e6b342d717165b71655 (diff) |
Ditch abbreviated field business.
Diffstat (limited to 'upb_parse.c')
-rw-r--r-- | upb_parse.c | 17 |
1 files changed, 17 insertions, 0 deletions
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 <assert.h> #include <stddef.h> +#include <stdlib.h> #include <string.h> #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); |