Visibility hidden by default
[babeltrace.git] / src / ctf-writer / field-wrapper.c
CommitLineData
16ca5ff0 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
16ca5ff0 3 *
0235b0db 4 * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
16ca5ff0
PP
5 */
6
350ad6c1 7#define BT_LOG_TAG "CTF-WRITER/FIELD-WRAPPER"
67d2ce02 8#include "logging.h"
16ca5ff0 9
16ca5ff0
PP
10#include <glib.h>
11
578e048b
MJ
12#include "fields.h"
13#include "field-wrapper.h"
14#include "object.h"
15
16ca5ff0
PP
16struct 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
e1e02a22 28 bt_ctf_object_init_unique(&field_wrapper->base);
16ca5ff0
PP
29 BT_LOGD("Created empty field wrapper object: addr=%p",
30 field_wrapper);
31
32end:
33 return field_wrapper;
34}
35
16ca5ff0
PP
36void bt_ctf_field_wrapper_destroy(struct bt_ctf_field_wrapper *field_wrapper)
37{
38 BT_LOGD("Destroying field wrapper: addr=%p", field_wrapper);
98b15851 39 BT_ASSERT_DBG(!field_wrapper->field);
16ca5ff0
PP
40 BT_LOGD_STR("Putting stream class.");
41 g_free(field_wrapper);
42}
43
16ca5ff0 44struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_create(
e1e02a22 45 struct bt_ctf_object_pool *pool, struct bt_ctf_field_type *ft)
16ca5ff0
PP
46{
47 struct bt_ctf_field_wrapper *field_wrapper = NULL;
48
98b15851
PP
49 BT_ASSERT_DBG(pool);
50 BT_ASSERT_DBG(ft);
e1e02a22 51 field_wrapper = bt_ctf_object_pool_create_object(pool);
16ca5ff0 52 if (!field_wrapper) {
67d2ce02 53 BT_LOGE("Cannot allocate one field wrapper");
a2845228 54 goto end;
16ca5ff0
PP
55 }
56
98b15851 57 BT_ASSERT_DBG(field_wrapper->field);
16ca5ff0
PP
58
59end:
60 return field_wrapper;
61}
This page took 0.072479 seconds and 4 git commands to generate.