Fix: bfcr_get_sequence_length_cb(): do not set text array's length
[babeltrace.git] / lib / trace-ir / field-path.c
index 65d2f7215b11a02c9064f0cb31866211d0106374..3303134b08ba3e248024642ac18ff90dd12877eb 100644 (file)
@@ -1,10 +1,6 @@
 /*
- * field-path.c
- *
- * Babeltrace trace IR - Field path
- *
+ * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
  * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
 #include <babeltrace/lib-logging-internal.h>
 
 #include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field-types.h>
-#include <babeltrace/trace-ir/field-types-internal.h>
+#include <babeltrace/trace-ir/field-class.h>
+#include <babeltrace/trace-ir/field-class-internal.h>
 #include <babeltrace/trace-ir/field-path-internal.h>
-#include <babeltrace/trace-ir/field-path.h>
+#include <babeltrace/trace-ir/field-path-const.h>
 #include <limits.h>
 #include <stdint.h>
 #include <inttypes.h>
@@ -47,6 +43,7 @@ void destroy_field_path(struct bt_object *obj)
        BT_ASSERT(field_path);
        BT_LIB_LOGD("Destroying field path: %!+P", field_path);
        g_array_free(field_path->indexes, TRUE);
+       field_path->indexes = NULL;
        g_free(field_path);
 }
 
@@ -74,28 +71,39 @@ struct bt_field_path *bt_field_path_create(void)
        goto end;
 
 error:
-       BT_PUT(field_path);
+       BT_OBJECT_PUT_REF_AND_RESET(field_path);
 
 end:
        return field_path;
 }
 
-enum bt_scope bt_field_path_get_root_scope(struct bt_field_path *field_path)
+enum bt_scope bt_field_path_get_root_scope(
+               const struct bt_field_path *field_path)
 {
        BT_ASSERT_PRE_NON_NULL(field_path, "Field path");
        return field_path->root;
 }
 
-uint64_t bt_field_path_get_index_count(struct bt_field_path *field_path)
+uint64_t bt_field_path_get_index_count(const struct bt_field_path *field_path)
 {
        BT_ASSERT_PRE_NON_NULL(field_path, "Field path");
        return (uint64_t) field_path->indexes->len;
 }
 
-uint64_t bt_field_path_get_index_by_index(struct bt_field_path *field_path,
-               uint64_t index)
+uint64_t bt_field_path_get_index_by_index(
+               const struct bt_field_path *field_path, uint64_t index)
 {
        BT_ASSERT_PRE_NON_NULL(field_path, "Field path");
        BT_ASSERT_PRE_VALID_INDEX(index, field_path->indexes->len);
        return bt_field_path_get_index_by_index_inline(field_path, index);
 }
+
+void bt_field_path_get_ref(const struct bt_field_path *field_path)
+{
+       bt_object_get_ref(field_path);
+}
+
+void bt_field_path_put_ref(const struct bt_field_path *field_path)
+{
+       bt_object_put_ref(field_path);
+}
This page took 0.023699 seconds and 4 git commands to generate.