From b82cd9f0ac23ce23386d4cf3d6b46aaf09293770 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 30 Nov 2015 09:03:04 -0500 Subject: [PATCH] Return pointer when using bt_get() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit bt_get() now returns the pointer it was passed to replace code of the form: bt_get(my_thingy); another_object->thingy = my_thingy; to the shorter form another_object->thingy = bt_get(my_thingy); Signed-off-by: Jérémie Galarneau --- include/babeltrace/ref.h | 4 +++- lib/ref.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/babeltrace/ref.h b/include/babeltrace/ref.h index a667f6f2..f03f8c9b 100644 --- a/include/babeltrace/ref.h +++ b/include/babeltrace/ref.h @@ -71,8 +71,10 @@ * It is safe to call this function with a NULL object. * * @param obj Babeltrace object. + * + * Returns obj. */ -void bt_get(void *obj); +void *bt_get(void *obj); /* * bt_put: decrements the reference count of a Babeltrace object. diff --git a/lib/ref.c b/lib/ref.c index 0ac1014c..e642e266 100644 --- a/lib/ref.c +++ b/lib/ref.c @@ -27,13 +27,14 @@ #include #include -void bt_get(void *obj) +void *bt_get(void *obj) { if (obj) { struct bt_object *base = obj; bt_ref_get(&base->ref_count); } + return obj; } void bt_put(void *obj) -- 2.34.1