summaryrefslogtreecommitdiff
path: root/upb/bytestream.c
diff options
context:
space:
mode:
Diffstat (limited to 'upb/bytestream.c')
-rw-r--r--upb/bytestream.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/upb/bytestream.c b/upb/bytestream.c
index 36be4b1..86095f9 100644
--- a/upb/bytestream.c
+++ b/upb/bytestream.c
@@ -21,6 +21,24 @@ char *upb_strref_dup(const struct _upb_strref *r) {
return ret;
}
+upb_strref *upb_strref_new(const char *str) {
+ return upb_strref_newl(str, strlen(str));
+}
+
+upb_strref *upb_strref_newl(const void *str, size_t len) {
+ upb_strref *s = malloc(sizeof(*s));
+ s->bytesrc = NULL;
+ s->ptr = malloc(len);
+ memcpy((void*)s->ptr, str, len);
+ return s;
+}
+
+void upb_strref_free(upb_strref *ref) {
+ if (!ref) return;
+ free((char*)ref->ptr);
+ free(ref);
+}
+
void upb_bytesink_init(upb_bytesink *sink, upb_bytesink_vtbl *vtbl) {
sink->vtbl = vtbl;
upb_status_init(&sink->status);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback