summaryrefslogtreecommitdiff
path: root/upb/refcounted.c
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2014-07-29 16:12:53 -0700
committerJosh Haberman <jhaberman@gmail.com>2014-07-29 16:12:53 -0700
commit43f2455cbda22c513f2885d760ca2766b23e100f (patch)
tree3068031b1f5cc16e530ad25408a3c5a7554a7a28 /upb/refcounted.c
parentd493500abc6def6b62d664990ed821e0a836a6cf (diff)
Added UPB_UNTRACKED_REF and some more handler overload options.
Diffstat (limited to 'upb/refcounted.c')
-rw-r--r--upb/refcounted.c9
1 files changed, 9 insertions, 0 deletions
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);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback