From: Jérémie Galarneau Date: Mon, 30 Nov 2015 14:03:04 +0000 (-0500) Subject: Return pointer when using bt_get() X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=b82cd9f0ac23ce23386d4cf3d6b46aaf09293770;p=deliverable%2Fbabeltrace.git Return pointer when using bt_get() 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 --- diff --git a/include/babeltrace/ref.h b/include/babeltrace/ref.h index a667f6f28..f03f8c9b0 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 0ac1014c6..e642e266d 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)