summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2011-02-06 12:42:35 -0800
committerJoshua Haberman <joshua@reverberate.org>2011-02-06 12:42:35 -0800
commit0313826cef64ca89058f32e3c8a2868e8f9e98df (patch)
treef83f48aa8fea6b70fb6b5290e5c38786301b660f /core
parent4667ed4be921b2142321e47c8ccc6a35a9189277 (diff)
Benchmarks compile and run again!
Diffstat (limited to 'core')
-rw-r--r--core/upb_string.c20
-rw-r--r--core/upb_string.h20
2 files changed, 20 insertions, 20 deletions
diff --git a/core/upb_string.c b/core/upb_string.c
index 297583b..30ed88f 100644
--- a/core/upb_string.c
+++ b/core/upb_string.c
@@ -48,30 +48,12 @@ uint32_t upb_string_size(upb_string *str) {
#endif
}
-static void upb_string_release(upb_string *str) {
- if(str->src) {
- upb_string_unref(str->src);
- str->src = NULL;
- }
-}
-
void _upb_string_free(upb_string *str) {
free(str->cached_mem);
- upb_string_release(str);
+ _upb_string_release(str);
free(str);
}
-void upb_string_recycle(upb_string **_str) {
- upb_string *str = *_str;
- if(str && upb_atomic_only(&str->refcount)) {
- str->ptr = NULL;
- upb_string_release(str);
- } else {
- upb_string_unref(str);
- *_str = upb_string_new();
- }
-}
-
char *upb_string_getrwbuf(upb_string *str, upb_strlen_t len) {
// assert(str->ptr == NULL);
upb_strlen_t size = upb_string_size(str);
diff --git a/core/upb_string.h b/core/upb_string.h
index 4943cbf..0694a23 100644
--- a/core/upb_string.h
+++ b/core/upb_string.h
@@ -112,6 +112,13 @@ INLINE void upb_string_unref(upb_string *str) {
}
}
+static void _upb_string_release(upb_string *str) {
+ if(str->src) {
+ upb_string_unref(str->src);
+ str->src = NULL;
+ }
+}
+
upb_string *upb_strdup(upb_string *s); // Forward-declare.
// Returns a string with the same contents as "str". The caller owns a ref on
@@ -158,7 +165,18 @@ INLINE const char *upb_string_getbufend(upb_string *str) {
// upb_src_getstr(str);
// }
// }
-void upb_string_recycle(upb_string **str);
+INLINE void upb_string_recycle(upb_string **_str) {
+ upb_string *str = *_str;
+ if(str && upb_atomic_only(&str->refcount)) {
+ str->ptr = NULL;
+ str->len = 0;
+ _upb_string_release(str);
+ } else {
+ upb_string_unref(str);
+ *_str = upb_string_new();
+ }
+}
+
// The options for setting the contents of a string. These may only be called
// when a string is first created or recycled; once other functions have been
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback