summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2011-01-25 10:07:47 -0800
committerJoshua Haberman <joshua@reverberate.org>2011-01-25 10:07:47 -0800
commit2c24cbb108bbda296f01e7628028b1dcb2b9516b (patch)
treedaa31a93b2c7d45de2df344eb2ec6e73b635bdb7 /core
parent93381f1411def0dba5677b71cd4df859d99777f3 (diff)
More work on decoder and stdio bytesrc/bytesink.
Diffstat (limited to 'core')
-rw-r--r--core/upb.c17
-rw-r--r--core/upb_stream.h16
2 files changed, 17 insertions, 16 deletions
diff --git a/core/upb.c b/core/upb.c
index ff2d47e..525c8a8 100644
--- a/core/upb.c
+++ b/core/upb.c
@@ -41,16 +41,13 @@ const upb_type_info upb_types[] = {
};
void upb_seterr(upb_status *status, enum upb_status_code code,
- const char *msg, ...)
-{
- if(upb_ok(status)) { // The first error is the most interesting.
- status->code = code;
- upb_string_recycle(&status->str);
- va_list args;
- va_start(args, msg);
- upb_string_vprintf(status->str, msg, args);
- va_end(args);
- }
+ const char *msg, ...) {
+ status->code = code;
+ upb_string_recycle(&status->str);
+ va_list args;
+ va_start(args, msg);
+ upb_string_vprintf(status->str, msg, args);
+ va_end(args);
}
void upb_copyerr(upb_status *to, upb_status *from)
diff --git a/core/upb_stream.h b/core/upb_stream.h
index bf312a8..d0045cc 100644
--- a/core/upb_stream.h
+++ b/core/upb_stream.h
@@ -178,12 +178,16 @@ INLINE void upb_src_run(upb_src *src, upb_status *status);
INLINE upb_strlen_t upb_bytesrc_read(upb_bytesrc *src, void *buf,
upb_strlen_t count, upb_status *status);
-// Like upb_bytesrc_read(), but modifies "str" in-place, possibly aliasing
-// existing string data (which avoids a copy). On the other hand, if
-// the data was *not* already in an existing string, this copies it into
-// a upb_string, and if the data needs to be put in a specific range of
-// memory (because eg. you need to put it into a different kind of string
-// object) then upb_bytesrc_get() could be better.
+// Like upb_bytesrc_read(), but modifies "str" in-place. "str" MUST be newly
+// created or just recycled. Returns "false" if no data was returned, either
+// due to error or EOF (check status for details).
+//
+// In comparison to upb_bytesrc_read(), this call can possibly alias existing
+// string data (which avoids a copy). On the other hand, if the data was *not*
+// already in an existing string, this copies it into a upb_string, and if the
+// data needs to be put in a specific range of memory (because eg. you need to
+// put it into a different kind of string object) then upb_bytesrc_get() could
+// be better.
INLINE bool upb_bytesrc_getstr(upb_bytesrc *src, upb_string *str,
upb_status *status);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback