summaryrefslogtreecommitdiff
path: root/upb_parse.c
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-07-07 16:59:08 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-07-07 16:59:08 -0700
commit127adf4036baa5d6c41d59b4e2b3462b4180c2d6 (patch)
treec4ddfa465ccdbcf695ca3e9804ecf2c8f75eaa86 /upb_parse.c
parent137991c7b2def357b9f18d0cd01ba671ebf1392d (diff)
More work on the benchmark.
Diffstat (limited to 'upb_parse.c')
-rw-r--r--upb_parse.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/upb_parse.c b/upb_parse.c
index 3195e71..dcad9c9 100644
--- a/upb_parse.c
+++ b/upb_parse.c
@@ -253,17 +253,23 @@ upb_status_t upb_parse_value(void **buf, void *end, upb_field_type_t ft,
#undef CASE
}
-void upb_parse_init(struct upb_parse_state *state, size_t udata_size)
+void upb_parse_reset(struct upb_parse_state *state)
{
- memset(state, 0, sizeof(struct upb_parse_state));
state->offset = 0;
- size_t stack_bytes = (sizeof(*state->stack) + udata_size) * UPB_MAX_NESTING;
- state->stack = state->top = malloc(stack_bytes);
+ state->top = state->stack;
/* The top-level message is not delimited (we can keep receiving data for
* it indefinitely). */
state->top->end_offset = SIZE_MAX;
+}
+
+void upb_parse_init(struct upb_parse_state *state, size_t udata_size)
+{
+ memset(state, 0, sizeof(struct upb_parse_state)); /* Clear all callbacks. */
+ size_t stack_bytes = (sizeof(*state->stack) + udata_size) * UPB_MAX_NESTING;
+ state->stack = malloc(stack_bytes);
state->limit = (struct upb_parse_stack_frame*)((char*)state->stack + stack_bytes);
state->udata_size = udata_size;
+ upb_parse_reset(state);
}
void upb_parse_free(struct upb_parse_state *state)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback