Return pointer when using bt_get()
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 30 Nov 2015 14:03:04 +0000 (09:03 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 19 Jan 2016 18:28:27 +0000 (13:28 -0500)
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 <jeremie.galarneau@efficios.com>
include/babeltrace/ref.h
lib/ref.c

index a667f6f28330023cca59fdc7d7b7a6eb0a51011b..f03f8c9b01f67c9494c8bbf6476a2a84f2e1159f 100644 (file)
  * 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.
index 0ac1014c626a47940d78d1da8a5d6f6c53f88194..e642e266de87543c24f9f3819e6c8b7a577c1b46 100644 (file)
--- a/lib/ref.c
+++ b/lib/ref.c
 #include <babeltrace/ref-internal.h>
 #include <babeltrace/object-internal.h>
 
-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)
This page took 0.026265 seconds and 4 git commands to generate.