ir: add BT_CTF_MOVE()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 22 Jul 2015 21:05:36 +0000 (17:05 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 28 Jul 2015 18:00:26 +0000 (14:00 -0400)
commite693822d3c00dbca7336ee2f9ba8f756599c7a3b
tree582225810cbe3b57e9fa0057b8af6c426ec571b3
parent0ae6f118a0ad01397a18c95efed9ce82dcd2ea71
ir: add BT_CTF_MOVE()

Adds semantics to ownership transfers of CTF IR objects.

This is something that is done often enough to justify the
existence of this macro:

    struct bt_ctf_field_type *type;
    struct bt_ctf_field_type *ret_type;

    /* ... */

    /* move ownership */
    ret_type = type;
    type = NULL;

    /* ... */

    /* put both (safe since type was set to NULL) */
    bt_ctf_put(ret_type);
    bt_ctf_put(type);

With BT_CTF_MOVE():

    struct bt_ctf_field_type *type;
    struct bt_ctf_field_type *ret_type;

    /* ... */

    /* move ownership */
    BT_CTF_MOVE(ret_type, type);

    /* ... */

    /* put both (safe since ownership was moved) */
    bt_ctf_put(ret_type);
    bt_ctf_put(type);

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/ctf-ir/ref.h
This page took 0.02685 seconds and 4 git commands to generate.