2 * SPDX-License-Identifier: MIT
4 * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
7 #define BT_LOG_TAG "LIB/FIELD-WRAPPER"
8 #include "lib/logging.h"
10 #include "lib/object-pool.h"
11 #include "lib/object.h"
14 #include "field-wrapper.h"
17 struct bt_field_wrapper
*bt_field_wrapper_new(void *data
__attribute__((unused
)))
19 struct bt_field_wrapper
*field_wrapper
=
20 g_new0(struct bt_field_wrapper
, 1);
22 BT_LOGD_STR("Creating empty field wrapper object.");
25 BT_LIB_LOGE_APPEND_CAUSE(
26 "Failed to allocate one field wrapper.");
30 bt_object_init_unique(&field_wrapper
->base
);
31 BT_LOGD("Created empty field wrapper object: addr=%p",
38 void bt_field_wrapper_destroy(struct bt_field_wrapper
*field_wrapper
)
40 BT_LOGD("Destroying field wrapper: addr=%p", field_wrapper
);
42 if (field_wrapper
->field
) {
43 BT_LOGD_STR("Destroying field.");
44 bt_field_destroy((void *) field_wrapper
->field
);
45 field_wrapper
->field
= NULL
;
48 BT_LOGD_STR("Putting stream class.");
49 g_free(field_wrapper
);
52 struct bt_field_wrapper
*bt_field_wrapper_create(
53 struct bt_object_pool
*pool
, struct bt_field_class
*fc
)
55 struct bt_field_wrapper
*field_wrapper
= NULL
;
59 field_wrapper
= bt_object_pool_create_object(pool
);
61 BT_LIB_LOGE_APPEND_CAUSE(
62 "Cannot allocate one field wrapper from field wrapper pool: "
67 if (!field_wrapper
->field
) {
68 field_wrapper
->field
= (void *) bt_field_create(fc
);
69 if (!field_wrapper
->field
) {
70 BT_LIB_LOGE_APPEND_CAUSE(
71 "Cannot create field wrapper from field class: "
76 BT_LIB_LOGD("Created initial field wrapper object: "
77 "wrapper-addr=%p, %![field-]+f", field_wrapper
,
78 field_wrapper
->field
);
85 bt_field_wrapper_destroy(field_wrapper
);
This page took 0.030993 seconds and 4 git commands to generate.