Rename: bt_put(), bt_get() -> bt_object_put_ref(), bt_object_get_ref()
[babeltrace.git] / cli / babeltrace-cfg-cli-args-connect.c
index 503e46af4ace2df60de685e051f85874d50693d3..fc692391110ab14f6411aeaaa682038ba9737002 100644 (file)
@@ -20,6 +20,7 @@
  * SOFTWARE.
  */
 
+#include <stdlib.h>
 #include <babeltrace/values.h>
 #include <babeltrace/common-internal.h>
 #include "babeltrace-cfg.h"
@@ -104,7 +105,7 @@ static bool validate_port_glob(const char *port_glob)
        bool is_valid = true;
        const char *ch = port_glob;
 
-       assert(port_glob);
+       BT_ASSERT(port_glob);
 
        while (*ch != '\0') {
                switch (*ch) {
@@ -268,7 +269,7 @@ static struct bt_config_connection *cfg_connection_from_arg(const char *arg)
                        }
                        break;
                default:
-                       assert(false);
+                       abort();
                }
        }
 
@@ -294,7 +295,7 @@ static struct bt_config_component *find_component_in_array(GPtrArray *comps,
                struct bt_config_component *comp = g_ptr_array_index(comps, i);
 
                if (strcmp(name, comp->instance_name->str) == 0) {
-                       found_comp = bt_get(comp);
+                       found_comp = bt_object_get_ref(comp);
                        goto end;
                }
        }
@@ -339,7 +340,7 @@ static int validate_all_endpoints_exist(struct bt_config *cfg, char *error_buf,
                struct bt_config_component *comp;
 
                comp = find_component(cfg, connection->upstream_comp_name->str);
-               bt_put(comp);
+               bt_object_put_ref(comp);
                if (!comp) {
                        snprintf(error_buf, error_buf_size,
                                "Invalid connection: cannot find upstream component `%s`:\n    %s\n",
@@ -350,7 +351,7 @@ static int validate_all_endpoints_exist(struct bt_config *cfg, char *error_buf,
                }
 
                comp = find_component(cfg, connection->downstream_comp_name->str);
-               bt_put(comp);
+               bt_object_put_ref(comp);
                if (!comp) {
                        snprintf(error_buf, error_buf_size,
                                "Invalid connection: cannot find downstream component `%s`:\n    %s\n",
@@ -379,10 +380,10 @@ static int validate_connection_directions(struct bt_config *cfg,
 
                src_comp = find_component(cfg,
                        connection->upstream_comp_name->str);
-               assert(src_comp);
+               BT_ASSERT(src_comp);
                dst_comp = find_component(cfg,
                        connection->downstream_comp_name->str);
-               assert(dst_comp);
+               BT_ASSERT(dst_comp);
 
                if (src_comp->type == BT_COMPONENT_CLASS_TYPE_SOURCE) {
                        if (dst_comp->type != BT_COMPONENT_CLASS_TYPE_FILTER &&
@@ -414,13 +415,13 @@ static int validate_connection_directions(struct bt_config *cfg,
                        goto end;
                }
 
-               BT_PUT(src_comp);
-               BT_PUT(dst_comp);
+               BT_OBJECT_PUT_REF_AND_RESET(src_comp);
+               BT_OBJECT_PUT_REF_AND_RESET(dst_comp);
        }
 
 end:
-       bt_put(src_comp);
-       bt_put(dst_comp);
+       bt_object_put_ref(src_comp);
+       bt_object_put_ref(dst_comp);
        return ret;
 }
 
@@ -431,7 +432,7 @@ static int validate_no_cycles_rec(struct bt_config *cfg, GPtrArray *path,
        size_t conn_i;
        const char *src_comp_name;
 
-       assert(path && path->len > 0);
+       BT_ASSERT(path && path->len > 0);
        src_comp_name = g_ptr_array_index(path, path->len - 1);
 
        for (conn_i = 0; conn_i < cfg->cmd_data.run.connections->len; conn_i++) {
@@ -514,7 +515,7 @@ static int validate_all_components_connected_in_array(GPtrArray *comps,
        for (i = 0; i < comps->len; i++) {
                struct bt_config_component *comp = g_ptr_array_index(comps, i);
 
-               if (!bt_value_map_has_key(connected_components,
+               if (!bt_value_map_has_entry(connected_components,
                                comp->instance_name->str)) {
                        snprintf(error_buf, error_buf_size,
                                "Component `%s` is not connected\n",
@@ -544,13 +545,13 @@ static int validate_all_components_connected(struct bt_config *cfg,
                struct bt_config_connection *connection =
                        g_ptr_array_index(cfg->cmd_data.run.connections, i);
 
-               ret = bt_value_map_insert(connected_components,
+               ret = bt_value_map_insert_entry(connected_components,
                        connection->upstream_comp_name->str, bt_value_null);
                if (ret) {
                        goto end;
                }
 
-               ret = bt_value_map_insert(connected_components,
+               ret = bt_value_map_insert_entry(connected_components,
                        connection->downstream_comp_name->str, bt_value_null);
                if (ret) {
                        goto end;
@@ -579,7 +580,7 @@ static int validate_all_components_connected(struct bt_config *cfg,
        }
 
 end:
-       bt_put(connected_components);
+       bt_object_put_ref(connected_components);
        return ret;
 }
 
@@ -612,7 +613,7 @@ static int validate_no_duplicate_connection(struct bt_config *cfg,
                        connection->downstream_comp_name->str,
                        connection->downstream_port_glob->str);
 
-               if (bt_value_map_has_key(flat_connection_names,
+               if (bt_value_map_has_entry(flat_connection_names,
                                flat_connection_name->str)) {
                        snprintf(error_buf, error_buf_size,
                                "Duplicate connection:\n    %s\n",
@@ -621,7 +622,7 @@ static int validate_no_duplicate_connection(struct bt_config *cfg,
                        goto end;
                }
 
-               ret = bt_value_map_insert(flat_connection_names,
+               ret = bt_value_map_insert_entry(flat_connection_names,
                        flat_connection_name->str, bt_value_null);
                if (ret) {
                        goto end;
@@ -629,7 +630,7 @@ static int validate_no_duplicate_connection(struct bt_config *cfg,
        }
 
 end:
-       bt_put(flat_connection_names);
+       bt_object_put_ref(flat_connection_names);
 
        if (flat_connection_name) {
                g_string_free(flat_connection_name, TRUE);
@@ -685,15 +686,15 @@ int bt_config_cli_args_create_connections(struct bt_config *cfg,
                goto error;
        }
 
-       for (i = 0; i < bt_value_array_size(connection_args); i++) {
+       for (i = 0; i < bt_value_array_get_size(connection_args); i++) {
                struct bt_value *arg_value =
-                       bt_value_array_get(connection_args, i);
+                       bt_value_array_borrow_element_by_index(
+                               connection_args, i);
                const char *arg;
                struct bt_config_connection *cfg_connection;
 
                ret = bt_value_string_get(arg_value, &arg);
-               BT_PUT(arg_value);
-               assert(ret == 0);
+               BT_ASSERT(ret == 0);
                cfg_connection = cfg_connection_from_arg(arg);
                if (!cfg_connection) {
                        snprintf(error_buf, error_buf_size, "Cannot parse --connect option's argument:\n    %s\n",
This page took 0.026162 seconds and 4 git commands to generate.