From: Philippe Proulx Date: Tue, 22 Nov 2016 09:30:33 +0000 (-0500) Subject: ref-internal.h: do not increment ref count if release not set X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=0c747e0de732637ad24f5d7c8c8671a55adcaf56;p=deliverable%2Fbabeltrace.git ref-internal.h: do not increment ref count if release not set 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 Signed-off-by: Jérémie Galarneau --- diff --git a/include/babeltrace/ref-internal.h b/include/babeltrace/ref-internal.h index 8578de97b..cf1547da9 100644 --- a/include/babeltrace/ref-internal.h +++ b/include/babeltrace/ref-internal.h @@ -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);