From e195d5379deb5699ea7cb76e4b3077a2cffa40da Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 26 Feb 2009 17:41:43 -0800 Subject: Since the stack has a fixed size, don't allocate dynamically. --- pbstream.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pbstream.h') diff --git a/pbstream.h b/pbstream.h index d564970..b8befc6 100644 --- a/pbstream.h +++ b/pbstream.h @@ -7,6 +7,9 @@ #include #include +/* The maximum that any submessages can be nested. Matches proto2's limit. */ +#define PBSTREAM_MAX_STACK 64 + /* A list of types as they can appear in a .proto file. */ typedef enum pbstream_type { PBSTREAM_TYPE_DOUBLE = 0, @@ -101,7 +104,8 @@ struct pbstream_parse_stack_frame { /* The stream parser's state. */ struct pbstream_parse_state { size_t offset; - struct pbstream_parse_stack_frame *base, *top, *limit; + struct pbstream_parse_stack_frame stack[PBSTREAM_MAX_STACK]; + struct pbstream_parse_stack_frame *top, *limit; }; /* Call this once before parsing to initialize the data structures. @@ -111,8 +115,6 @@ void pbstream_init_parser( struct pbstream_parse_state *state, struct pbstream_fieldset *toplevel_fieldset); -void pbstream_free_parser(struct pbstream_parse_state *state); - /* Status as returned by pbstream_parse(). Status codes <0 are fatal errors * that cannot be recovered. Status codes >0 are unusual but nonfatal events, * which nonetheless must be handled differently since they do not return data -- cgit v1.2.3