From 43f2455cbda22c513f2885d760ca2766b23e100f Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Tue, 29 Jul 2014 16:12:53 -0700 Subject: Added UPB_UNTRACKED_REF and some more handler overload options. --- upb/refcounted.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'upb/refcounted.c') diff --git a/upb/refcounted.c b/upb/refcounted.c index 4e01081..cba535f 100644 --- a/upb/refcounted.c +++ b/upb/refcounted.c @@ -25,6 +25,9 @@ static void freeobj(upb_refcounted *o); +const char untracked_val; +const void *UPB_UNTRACKED_REF = &untracked_val; + /* arch-specific atomic primitives *******************************************/ #ifdef UPB_THREAD_UNSAFE ////////////////////////////////////////////////////// @@ -111,6 +114,9 @@ static trackedref *trackedref_new(bool is_ref2) { } static void track(const upb_refcounted *r, const void *owner, bool ref2) { + assert(owner); + if (owner == UPB_UNTRACKED_REF) return; + upb_lock(); upb_value v; if (upb_inttable_lookupptr(r->refs, owner, &v)) { @@ -140,6 +146,9 @@ static void track(const upb_refcounted *r, const void *owner, bool ref2) { } static void untrack(const upb_refcounted *r, const void *owner, bool ref2) { + assert(owner); + if (owner == UPB_UNTRACKED_REF) return; + upb_lock(); upb_value v; bool found = upb_inttable_lookupptr(r->refs, owner, &v); -- cgit v1.2.3