summaryrefslogtreecommitdiff
path: root/upb_parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'upb_parse.c')
-rw-r--r--upb_parse.c17
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);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback