|
|
|
@ -14,11 +14,14 @@ |
|
|
|
|
void upb_streamdata(upb_src *src, upb_sink *sink, upb_status *status) { |
|
|
|
|
upb_fielddef *f; |
|
|
|
|
upb_string *str = NULL; |
|
|
|
|
int depth = 0; |
|
|
|
|
while(1) { |
|
|
|
|
while((f = upb_src_getdef(src)) != NULL) { |
|
|
|
|
CHECKSINK(upb_sink_putdef(sink, f)); |
|
|
|
|
if(upb_issubmsg(f)) { |
|
|
|
|
// We always recurse into submessages, but the putdef above already told
|
|
|
|
|
// the sink that.
|
|
|
|
|
upb_src_startmsg(src); |
|
|
|
|
upb_sink_startmsg(sink); |
|
|
|
|
++depth; |
|
|
|
|
} else if(upb_isstring(f)) { |
|
|
|
|
str = upb_string_tryrecycle(str); |
|
|
|
|
CHECKSRC(upb_src_getstr(src, str)); |
|
|
|
@ -32,6 +35,9 @@ void upb_streamdata(upb_src *src, upb_sink *sink, upb_status *status) { |
|
|
|
|
} |
|
|
|
|
// If we're not EOF now, the loop terminated due to an error.
|
|
|
|
|
CHECKSRC(upb_src_eof(src)); |
|
|
|
|
if (depth == 0) break; |
|
|
|
|
--depth; |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
src_err: |
|
|
|
|