lib: use object pool for event and packet notifications
[babeltrace.git] / plugins / ctf / fs-src / query.c
index 04bf8c5b0e301996d353e2965578d4cba020addd..96bf91ca0eaa11c7a6a67934d66527c1377ad0e9 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "query.h"
 #include <stdbool.h>
-#include <assert.h>
+#include <babeltrace/assert-internal.h>
 #include "metadata.h"
 #include "../common/metadata/decoder.h"
 #include <babeltrace/common-internal.h>
@@ -70,13 +70,15 @@ struct bt_component_class_query_method_return metadata_info_query(
                goto error;
        }
 
+       BT_ASSERT(params);
+
        if (!bt_value_is_map(params)) {
                BT_LOGE_STR("Query parameters is not a map value object.");
                query_ret.status = BT_QUERY_STATUS_INVALID_PARAMS;
                goto error;
        }
 
-       path_value = bt_value_map_get(params, "path");
+       path_value = bt_value_map_borrow(params, "path");
        ret = bt_value_string_get(path_value, &path);
        if (ret) {
                BT_LOGE_STR("Cannot get `path` string parameter.");
@@ -84,7 +86,7 @@ struct bt_component_class_query_method_return metadata_info_query(
                goto error;
        }
 
-       assert(path);
+       BT_ASSERT(path);
        metadata_fp = ctf_fs_metadata_open_file(path);
        if (!metadata_fp) {
                BT_LOGE("Cannot open trace metadata: path=\"%s\".", path);
@@ -170,7 +172,6 @@ error:
        }
 
 end:
-       bt_put(path_value);
        free(metadata_text);
 
        if (g_metadata_text) {
@@ -245,7 +246,7 @@ int add_stream_ids(struct bt_value *info, struct bt_stream *stream)
                }
        }
 
-       stream_class = bt_stream_get_class(stream);
+       stream_class = bt_stream_borrow_class(stream);
        if (!stream_class) {
                ret = -1;
                goto end;
@@ -262,8 +263,8 @@ int add_stream_ids(struct bt_value *info, struct bt_stream *stream)
                ret = -1;
                goto end;
        }
+
 end:
-       bt_put(stream_class);
        return ret;
 }
 
@@ -380,14 +381,14 @@ int populate_trace_info(const char *trace_path, const char *trace_name,
                goto end;
        }
 
-       trace = ctf_fs_trace_create(trace_path, trace_name, NULL);
+       trace = ctf_fs_trace_create(trace_path, trace_name, NULL, NULL);
        if (!trace) {
                BT_LOGE("Failed to create fs trace at \'%s\'", trace_path);
                ret = -1;
                goto end;
        }
 
-       assert(trace->ds_file_groups);
+       BT_ASSERT(trace->ds_file_groups);
        /* Add trace range info only if it contains streams. */
        if (trace->ds_file_groups->len == 0) {
                ret = -1;
@@ -479,13 +480,15 @@ struct bt_component_class_query_method_return trace_info_query(
        GList *tn_node = NULL;
        GString *normalized_path = NULL;
 
+       BT_ASSERT(params);
+
        if (!bt_value_is_map(params)) {
                BT_LOGE("Query parameters is not a map value object.");
                query_ret.status = BT_QUERY_STATUS_INVALID_PARAMS;
                goto error;
        }
 
-       path_value = bt_value_map_get(params, "path");
+       path_value = bt_value_map_borrow(params, "path");
        ret = bt_value_string_get(path_value, &path);
        if (ret) {
                BT_LOGE("Cannot get `path` string parameter.");
@@ -498,7 +501,7 @@ struct bt_component_class_query_method_return trace_info_query(
                BT_LOGE("Failed to normalize path: `%s`.", path);
                goto error;
        }
-       assert(path);
+       BT_ASSERT(path);
 
        ret = ctf_fs_find_traces(&trace_paths, normalized_path->str);
        if (ret) {
@@ -577,6 +580,5 @@ end:
                g_list_free(trace_names);
        }
        /* "path" becomes invalid with the release of path_value. */
-       bt_put(path_value);
        return query_ret;
 }
This page took 0.032433 seconds and 4 git commands to generate.