1 #ifndef BABELTRACE_CTF_IR_REF_H
2 #define BABELTRACE_CTF_IR_REF_H
5 * BabelTrace - CTF IR: common reference counting
7 * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
8 * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include <babeltrace/ref-internal.h>
31 #include <babeltrace/ctf-ir/common-internal.h>
34 * BT_CTF_PUT: calls bt_ctf_put() with a variable, then sets this
37 * A common action with CTF IR objects is to create or get one, do
38 * something with it, and then put it. To avoid putting it a second time
39 * later (if an error occurs, for example), the variable is often reset
40 * to NULL after putting the object it points to. Since this is so
41 * common, you can use the BT_CTF_PUT() macro, which does just that.
43 * It is safe to call this function with a NULL object.
45 * @param obj CTF IR object.
47 #define BT_CTF_PUT(_obj) \
54 * bt_ctf_get: increments the reference count of a CTF IR object.
56 * The same number of bt_ctf_get() and bt_ctf_put() (plus one extra
57 * bt_ctf_put() to release the initial reference done at creation) have
58 * to be done to destroy a CTF IR object.
60 * It is safe to call this function with a NULL object.
62 * @param obj CTF IR object.
65 void bt_ctf_get(void *obj
)
68 struct bt_ctf_base
*base
= obj
;
70 bt_ref_get(&base
->ref_count
);
75 * bt_ctf_put: decrements the reference count of a CTF IR object.
77 * The same number of bt_ctf_get() and bt_ctf_put() (plus one extra
78 * bt_ctf_put() to release the initial reference done at creation) have
79 * to be done to destroy a CTF IR object.
81 * When the object's reference count is decremented to 0 by a call to
82 * bt_ctf_put(), the object is freed.
84 * It is safe to call this function with a NULL object.
86 * @param obj CTF IR object.
89 void bt_ctf_put(void *obj
)
92 struct bt_ctf_base
*base
= obj
;
94 bt_ref_put(&base
->ref_count
);
98 #endif /* BABELTRACE_CTF_IR_REF_H */
This page took 0.034276 seconds and 6 git commands to generate.