summaryrefslogtreecommitdiff
path: root/src/upb_msg.c
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2011-05-21 17:35:21 -0700
committerJoshua Haberman <joshua@reverberate.org>2011-05-21 17:35:21 -0700
commita503b8859c37906ab5012db163daca43bfe393bb (patch)
treebabc144389856dbe29bacb48bdbe267b9a48e5b8 /src/upb_msg.c
parent2ccebb74c309c7ea4c4589b35893cdd6c996ac4b (diff)
Make all handlers objects refcounted.
I'm realizing that basically all upb objects will need to be refcounted to be sharable across languages, but *not* messages which are on their way out so we can get out of the business of data representations. Things which must be refcounted: - encoders, decoders - handlers objects - defs
Diffstat (limited to 'src/upb_msg.c')
-rw-r--r--src/upb_msg.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/upb_msg.c b/src/upb_msg.c
index 9f1f00d..91f1454 100644
--- a/src/upb_msg.c
+++ b/src/upb_msg.c
@@ -38,7 +38,7 @@ static void upb_elem_free(upb_value v, upb_fielddef *f) {
static void upb_elem_unref(upb_value v, upb_fielddef *f) {
assert(upb_elem_ismm(f));
- upb_atomic_refcount_t *refcount = upb_value_getrefcount(v);
+ upb_atomic_t *refcount = upb_value_getrefcount(v);
if (refcount && upb_atomic_unref(refcount))
upb_elem_free(v, f);
}
@@ -53,7 +53,7 @@ static void upb_field_free(upb_value v, upb_fielddef *f) {
static void upb_field_unref(upb_value v, upb_fielddef *f) {
assert(upb_field_ismm(f));
- upb_atomic_refcount_t *refcount = upb_value_getrefcount(v);
+ upb_atomic_t *refcount = upb_value_getrefcount(v);
if (refcount && upb_atomic_unref(refcount))
upb_field_free(v, f);
}
@@ -63,7 +63,7 @@ static void upb_field_unref(upb_value v, upb_fielddef *f) {
upb_array *upb_array_new(void) {
upb_array *arr = malloc(sizeof(*arr));
- upb_atomic_refcount_init(&arr->refcount, 1);
+ upb_atomic_init(&arr->refcount, 1);
arr->size = 0;
arr->len = 0;
arr->ptr = NULL;
@@ -134,7 +134,7 @@ upb_msg *upb_msg_new(upb_msgdef *md) {
upb_msg *msg = malloc(md->size);
// Clear all set bits and cached pointers.
memset(msg, 0, md->size);
- upb_atomic_refcount_init(&msg->refcount, 1);
+ upb_atomic_init(&msg->refcount, 1);
return msg;
}
@@ -178,7 +178,7 @@ void upb_msg_set(upb_msg *msg, upb_fielddef *f, upb_value val) {
upb_field_unref(oldval, f);
// Ref the new value.
- upb_atomic_refcount_t *refcount = upb_value_getrefcount(val);
+ upb_atomic_t *refcount = upb_value_getrefcount(val);
if (refcount) upb_atomic_ref(refcount);
}
upb_msg_sethas(msg, f);
@@ -194,7 +194,7 @@ upb_value upb_msg_get(upb_msg *msg, upb_fielddef *f) {
upb_msg *m = upb_msg_new(md);
// Copy all set bits and values, except the refcount.
memcpy(m , upb_value_getmsg(val), md->size);
- upb_atomic_refcount_init(&m->refcount, 0); // The msg will take a ref.
+ upb_atomic_init(&m->refcount, 0); // The msg will take a ref.
upb_value_setmsg(&val, m);
}
upb_msg_set(msg, f, val);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback