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.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/upb_string.c b/core/upb_string.c
index 3563c9e..ca3c669 100644
--- a/core/upb_string.c
+++ b/core/upb_string.c
@@ -61,12 +61,12 @@ void _upb_string_free(upb_string *str) {
}
upb_string *upb_string_tryrecycle(upb_string *str) {
- if(str == NULL || upb_atomic_read(&str->refcount) > 1) {
- return upb_string_new();
- } else {
+ if(str && upb_atomic_read(&str->refcount) == 1) {
str->ptr = NULL;
upb_string_release(str);
return str;
+ } else {
+ return upb_string_new();
}
}
@@ -125,3 +125,9 @@ upb_string *upb_string_asprintf(const char *format, ...) {
va_end(args);
return str;
}
+
+upb_string *upb_strdup(upb_string *s) {
+ upb_string *str = upb_string_new();
+ upb_strcpy(str, s);
+ return str;
+}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback