diff options
author | Joshua Haberman <joshua@reverberate.org> | 2010-12-06 15:52:40 -0800 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2010-12-06 15:52:40 -0800 |
commit | b471ca6b81b88dc23aae6a53345d94d9a2714a7c (patch) | |
tree | 87626d9f55bc234be7308e58ae9e3add87768d62 /core/upb_string.c | |
parent | 2a7f51f3fd534b3e9e098c522cffbb96e1551474 (diff) |
The last major revision to the upb_stream protocol.
Sources and sinks communicate by means of a
upb_handlers object, which encapsulates a set of
handler callbacks and will possibly offer richer
semantics in the future like giving specific
fields different callbacks.
The upb_handlers protocol supports delegation, so
sets of handlers can be written in reusable ways.
For example, if a set of handlers is written to
handle a specific .proto type, those handlers can
be used whether that type is at the top level or
whether it is a sub-message of a higher-level type.
Delegation allows the streaming protocol to
properly compose.
Diffstat (limited to 'core/upb_string.c')
-rw-r--r-- | core/upb_string.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/upb_string.c b/core/upb_string.c index 847a3ee..4f5f5c2 100644 --- a/core/upb_string.c +++ b/core/upb_string.c @@ -29,6 +29,7 @@ upb_string *upb_string_new() { upb_string *str = malloc(sizeof(*str)); str->ptr = NULL; str->cached_mem = NULL; + str->len = 0; #ifndef UPB_HAVE_MSIZE str->size = 0; #endif @@ -132,6 +133,14 @@ upb_string *upb_strdup(upb_string *s) { return str; } +void upb_strcat(upb_string *s, upb_string *append) { + uint32_t old_size = upb_string_len(s); + uint32_t append_size = upb_string_len(append); + uint32_t new_size = old_size + append_size; + char *buf = upb_string_getrwbuf(s, new_size); + memcpy(buf + old_size, upb_string_getrobuf(append), append_size); +} + upb_string *upb_strreadfile(const char *filename) { FILE *f = fopen(filename, "rb"); if(!f) return NULL; |