From e15f834a916d64b80a0da9cdc4ee0bd4439b6bf4 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sun, 6 Dec 2009 13:41:37 -0800 Subject: Circular references truly work now, along with a test. One simplification to come. --- src/upb_def.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/upb_def.h') diff --git a/src/upb_def.h b/src/upb_def.h index 09ae5d2..bc7e733 100644 --- a/src/upb_def.h +++ b/src/upb_def.h @@ -49,9 +49,9 @@ enum upb_def_type { // This typedef is more space-efficient than declaring an enum var directly. typedef uint8_t upb_def_type_t; -// Common members. struct upb_def { struct upb_string *fqname; // Fully qualified. + upb_atomic_refcount_t refcount; upb_def_type_t type; // These members that pertain to cyclic collection could technically go in @@ -60,11 +60,10 @@ struct upb_def { // because structure alignment will otherwise leave three bytes empty between // type and refcount. It is also makes ref and unref more efficient, because // we don't have to downcast to msgdef before checking the is_cyclic flag. - bool is_cyclic; // Is this def part of a cycle? - upb_field_count_t visiting_submsg; // Helper for depth-first search. - + // // See .c file for description of refcounting scheme. - upb_atomic_refcount_t refcount; + uint8_t max_cycle_len; + upb_field_count_t visiting_submsg; // Used during initialization dfs. upb_atomic_refcount_t cycle_refcount; }; @@ -113,6 +112,7 @@ struct upb_fielddef { // For the case of an enum or a submessage, points to the def for that type. // We own a ref on this def. + bool owned; struct upb_def *def; }; -- cgit v1.2.3