From 0c747e0de732637ad24f5d7c8c8671a55adcaf56 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 22 Nov 2016 04:30:33 -0500 Subject: [PATCH] ref-internal.h: do not increment ref count if release not set MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- include/babeltrace/ref-internal.h | 5 +++++ 1 file changed, 5 insertions(+) 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); -- 2.34.1