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