Visibility hidden by default
[babeltrace.git] / src / ctf-writer / field-wrapper.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
5 */
6
7 #define BT_LOG_TAG "CTF-WRITER/FIELD-WRAPPER"
8 #include "logging.h"
9
10 #include <glib.h>
11
12 #include "fields.h"
13 #include "field-wrapper.h"
14 #include "object.h"
15
16 struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_new(void *data)
17 {
18 struct bt_ctf_field_wrapper *field_wrapper =
19 g_new0(struct bt_ctf_field_wrapper, 1);
20
21 BT_LOGD_STR("Creating empty field wrapper object.");
22
23 if (!field_wrapper) {
24 BT_LOGE("Failed to allocate one field wrapper.");
25 goto end;
26 }
27
28 bt_ctf_object_init_unique(&field_wrapper->base);
29 BT_LOGD("Created empty field wrapper object: addr=%p",
30 field_wrapper);
31
32 end:
33 return field_wrapper;
34 }
35
36 void bt_ctf_field_wrapper_destroy(struct bt_ctf_field_wrapper *field_wrapper)
37 {
38 BT_LOGD("Destroying field wrapper: addr=%p", field_wrapper);
39 BT_ASSERT_DBG(!field_wrapper->field);
40 BT_LOGD_STR("Putting stream class.");
41 g_free(field_wrapper);
42 }
43
44 struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_create(
45 struct bt_ctf_object_pool *pool, struct bt_ctf_field_type *ft)
46 {
47 struct bt_ctf_field_wrapper *field_wrapper = NULL;
48
49 BT_ASSERT_DBG(pool);
50 BT_ASSERT_DBG(ft);
51 field_wrapper = bt_ctf_object_pool_create_object(pool);
52 if (!field_wrapper) {
53 BT_LOGE("Cannot allocate one field wrapper");
54 goto end;
55 }
56
57 BT_ASSERT_DBG(field_wrapper->field);
58
59 end:
60 return field_wrapper;
61 }
This page took 0.031046 seconds and 4 git commands to generate.