ref-internal.h: do not increment ref count if release not set
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 22 Nov 2016 09:30:33 +0000 (04:30 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:07 +0000 (14:09 -0400)
A singleton BT object can choose to opt-out of the reference count
mechanism. The way to do this is to set the release callback to
NULL. When this is the case, do not increment its reference count;
keep it at its original value.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/ref-internal.h

index 8578de97b2ec1808eded8e9887961c1e3e7f4644..cf1547da9615345df8977f5fd95c8d7fb4fe3a57 100644 (file)
@@ -50,6 +50,11 @@ static inline
 void bt_ref_get(struct bt_ref *ref)
 {
        assert(ref);
+
+       if (!ref->release) {
+               return;
+       }
+
        ref->count++;
        /* Overflow check. */
        assert(ref->count);
This page took 0.025925 seconds and 4 git commands to generate.