| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation |
| 5 | */ |
| 6 | |
| 7 | #ifndef BABELTRACE2_CTF_WRITER_EVENT_FIELDS_H |
| 8 | #define BABELTRACE2_CTF_WRITER_EVENT_FIELDS_H |
| 9 | |
| 10 | #include <babeltrace2-ctf-writer/object.h> |
| 11 | #include <babeltrace2-ctf-writer/field-types.h> |
| 12 | #include <babeltrace2-ctf-writer/fields.h> |
| 13 | |
| 14 | #ifdef __cplusplus |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | /* |
| 19 | * bt_ctf_field_get and bt_ctf_field_put: increment and decrement the |
| 20 | * field's reference count. |
| 21 | * |
| 22 | * You may also use bt_ctf_object_get_ref() and bt_ctf_object_put_ref() with field objects. |
| 23 | * |
| 24 | * These functions ensure that the field won't be destroyed when it |
| 25 | * is in use. The same number of get and put (plus one extra put to |
| 26 | * release the initial reference done at creation) have to be done to |
| 27 | * destroy a field. |
| 28 | * |
| 29 | * When the field's reference count is decremented to 0 by a bt_ctf_field_put, |
| 30 | * the field is freed. |
| 31 | * |
| 32 | * @param field Field instance. |
| 33 | */ |
| 34 | |
| 35 | /* Pre-2.0 CTF writer compatibility */ |
| 36 | static inline |
| 37 | void bt_ctf_field_get(struct bt_ctf_field *field) |
| 38 | { |
| 39 | bt_ctf_object_get_ref(field); |
| 40 | } |
| 41 | |
| 42 | /* Pre-2.0 CTF writer compatibility */ |
| 43 | static inline |
| 44 | void bt_ctf_field_put(struct bt_ctf_field *field) |
| 45 | { |
| 46 | bt_ctf_object_put_ref(field); |
| 47 | } |
| 48 | |
| 49 | #ifdef __cplusplus |
| 50 | } |
| 51 | #endif |
| 52 | |
| 53 | #endif /* BABELTRACE2_CTF_WRITER_EVENT_FIELDS_H */ |