summaryrefslogtreecommitdiff
path: root/src/upb_def.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_def.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_def.c')
-rw-r--r--src/upb_def.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/upb_def.c b/src/upb_def.c
index a6fe041..791b885 100644
--- a/src/upb_def.c
+++ b/src/upb_def.c
@@ -172,7 +172,7 @@ static void upb_def_init(upb_def *def, upb_deftype type) {
def->is_cyclic = 0; // We detect this later, after resolving refs.
def->search_depth = 0;
def->fqname = NULL;
- upb_atomic_refcount_init(&def->refcount, 1);
+ upb_atomic_init(&def->refcount, 1);
}
static void upb_def_uninit(upb_def *def) {
@@ -868,7 +868,7 @@ static upb_flow_t upb_msgdef_startmsg(void *_b) {
upb_defbuilder *b = _b;
upb_msgdef *m = malloc(sizeof(*m));
upb_def_init(&m->base, UPB_DEF_MSG);
- upb_atomic_refcount_init(&m->cycle_refcount, 0);
+ upb_atomic_init(&m->cycle_refcount, 0);
upb_inttable_init(&m->itof, 4, sizeof(upb_itof_ent));
upb_strtable_init(&m->ntof, 4, sizeof(upb_ntof_ent));
m->default_message = NULL;
@@ -898,7 +898,7 @@ static void upb_msgdef_endmsg(void *_b, upb_status *status) {
// Assign offsets in the msg.
m->set_flags_bytes = upb_div_round_up(n, 8);
- m->size = sizeof(upb_atomic_refcount_t) + m->set_flags_bytes;
+ m->size = sizeof(upb_atomic_t) + m->set_flags_bytes;
size_t max_align = 0;
for (int i = 0; i < n; i++) {
@@ -926,7 +926,7 @@ static void upb_msgdef_endmsg(void *_b, upb_status *status) {
// whole must be a multiple of the greatest alignment of any member.
size_t offset = upb_align_up(m->size, align);
// Offsets are relative to the end of the refcount.
- f->byte_offset = offset - sizeof(upb_atomic_refcount_t);
+ f->byte_offset = offset - sizeof(upb_atomic_t);
m->size = offset + size;
max_align = UPB_MAX(max_align, align);
}
@@ -1242,7 +1242,7 @@ err:
upb_symtab *upb_symtab_new()
{
upb_symtab *s = malloc(sizeof(*s));
- upb_atomic_refcount_init(&s->refcount, 1);
+ upb_atomic_init(&s->refcount, 1);
upb_rwlock_init(&s->lock);
upb_strtable_init(&s->symtab, 16, sizeof(upb_symtab_ent));
s->fds_msgdef = NULL;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback