projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib: update and simplify the `bt_object` API
[babeltrace.git]
/
lib
/
ctf-ir
/
field-path.c
diff --git
a/lib/ctf-ir/field-path.c
b/lib/ctf-ir/field-path.c
index bc991f4070943d5d0c901bdbb81ac5b0d634b5ff..d9893059e4bb8001e3e2ae14269dd71191542f9f 100644
(file)
--- a/
lib/ctf-ir/field-path.c
+++ b/
lib/ctf-ir/field-path.c
@@
-25,17
+25,25
@@
* SOFTWARE.
*/
* SOFTWARE.
*/
+#define BT_LOG_TAG "FIELD-PATH"
+#include <babeltrace/lib-logging-internal.h>
+
#include <babeltrace/ctf-ir/field-types.h>
#include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace/ctf-ir/field-types-internal.h>
#include <babeltrace/ctf-ir/field-path-internal.h>
#include <babeltrace/ctf-ir/field-path.h>
#include <limits.h>
#include <stdint.h>
#include <babeltrace/ctf-ir/field-path-internal.h>
#include <babeltrace/ctf-ir/field-path.h>
#include <limits.h>
#include <stdint.h>
+#include <inttypes.h>
+#include <babeltrace/assert-internal.h>
#include <glib.h>
static
void field_path_destroy(struct bt_object *obj)
{
#include <glib.h>
static
void field_path_destroy(struct bt_object *obj)
{
- struct bt_ctf_field_path *field_path = (struct bt_ctf_field_path *) obj;
+ struct bt_field_path *field_path = (struct bt_field_path *) obj;
+
+ BT_LOGD("Destroying field path: addr=%p", obj);
if (!field_path) {
return;
if (!field_path) {
return;
@@
-48,22
+56,27
@@
void field_path_destroy(struct bt_object *obj)
}
BT_HIDDEN
}
BT_HIDDEN
-struct bt_
ctf_field_path *bt_ctf
_field_path_create(void)
+struct bt_
field_path *bt
_field_path_create(void)
{
{
- struct bt_ctf_field_path *field_path = NULL;
+ struct bt_field_path *field_path = NULL;
+
+ BT_LOGD_STR("Creating empty field path object.");
- field_path = g_new0(struct bt_
ctf_
field_path, 1);
+ field_path = g_new0(struct bt_field_path, 1);
if (!field_path) {
if (!field_path) {
+ BT_LOGE_STR("Failed to allocate one field path.");
goto error;
}
goto error;
}
- bt_object_init
(field_path
, field_path_destroy);
- field_path->root = BT_
CTF_
SCOPE_UNKNOWN;
+ bt_object_init
_shared(&field_path->base
, field_path_destroy);
+ field_path->root = BT_SCOPE_UNKNOWN;
field_path->indexes = g_array_new(TRUE, FALSE, sizeof(int));
if (!field_path->indexes) {
field_path->indexes = g_array_new(TRUE, FALSE, sizeof(int));
if (!field_path->indexes) {
+ BT_LOGE_STR("Failed to allocate a GArray.");
goto error;
}
goto error;
}
+ BT_LOGD("Created empty field path object: addr=%p", field_path);
return field_path;
error:
return field_path;
error:
@@
-72,7
+85,7
@@
error:
}
BT_HIDDEN
}
BT_HIDDEN
-void bt_
ctf_field_path_clear(struct bt_ctf
_field_path *field_path)
+void bt_
field_path_clear(struct bt
_field_path *field_path)
{
if (field_path->indexes->len > 0) {
g_array_remove_range(field_path->indexes, 0,
{
if (field_path->indexes->len > 0) {
g_array_remove_range(field_path->indexes, 0,
@@
-81,28
+94,36
@@
void bt_ctf_field_path_clear(struct bt_ctf_field_path *field_path)
}
BT_HIDDEN
}
BT_HIDDEN
-struct bt_
ctf_field_path *bt_ctf
_field_path_copy(
- struct bt_
ctf_
field_path *path)
+struct bt_
field_path *bt
_field_path_copy(
+ struct bt_field_path *path)
{
{
- struct bt_
ctf_field_path *new_path = bt_ctf_field_path_create()
;
+ struct bt_
field_path *new_path
;
+ BT_ASSERT(path);
+ BT_LOGD("Copying field path: addr=%p, index-count=%u",
+ path, path->indexes->len);
+ new_path = bt_field_path_create();
if (!new_path) {
if (!new_path) {
+ BT_LOGE_STR("Cannot create empty field path.");
goto end;
}
new_path->root = path->root;
g_array_insert_vals(new_path->indexes, 0,
path->indexes->data, path->indexes->len);
goto end;
}
new_path->root = path->root;
g_array_insert_vals(new_path->indexes, 0,
path->indexes->data, path->indexes->len);
+ BT_LOGD("Copied field path: original-addr=%p, copy-addr=%p",
+ path, new_path);
end:
return new_path;
}
end:
return new_path;
}
-enum bt_
ctf_scope bt_ctf
_field_path_get_root_scope(
- const struct bt_
ctf_
field_path *field_path)
+enum bt_
scope bt
_field_path_get_root_scope(
+ const struct bt_field_path *field_path)
{
{
- enum bt_
ctf_scope scope = BT_CTF
_SCOPE_UNKNOWN;
+ enum bt_
scope scope = BT
_SCOPE_UNKNOWN;
if (!field_path) {
if (!field_path) {
+ BT_LOGW_STR("Invalid parameter: field path is NULL.");
goto end;
}
goto end;
}
@@
-112,22
+133,36
@@
end:
return scope;
}
return scope;
}
-int64_t bt_
ctf_
field_path_get_index_count(
- const struct bt_
ctf_
field_path *field_path)
+int64_t bt_field_path_get_index_count(
+ const struct bt_field_path *field_path)
{
{
- return field_path ? (int64_t) field_path->indexes->len : (int64_t) -1;
+ int64_t count = (int64_t) -1;
+
+ if (!field_path) {
+ BT_LOGW_STR("Invalid parameter: field path is NULL.");
+ goto end;
+ }
+
+ count = (int64_t) field_path->indexes->len;
+
+end:
+ return count;
}
}
-int bt_
ctf_field_path_get_index(const struct bt_ctf
_field_path *field_path,
+int bt_
field_path_get_index(const struct bt
_field_path *field_path,
uint64_t index)
{
int ret = INT_MIN;
if (!field_path) {
uint64_t index)
{
int ret = INT_MIN;
if (!field_path) {
+ BT_LOGW_STR("Invalid parameter: field path is NULL.");
goto end;
}
if (index >= field_path->indexes->len) {
goto end;
}
if (index >= field_path->indexes->len) {
+ BT_LOGW("Invalid parameter: index is out of bounds: "
+ "addr=%p, index=%" PRIu64 ", count=%u",
+ field_path, index, field_path->indexes->len);
goto end;
}
goto end;
}
This page took
0.043892 seconds
and
4
git commands to generate.