lib, bt2: add precondition check for port name unicity
[babeltrace.git] / src / lib / graph / component.c
index 26da38be78524a77c578898fd8d4a259a2f2b18e..d42dba7fc1ae8f6363f24a1743ade06102cdf792 100644 (file)
@@ -464,6 +464,27 @@ enum bt_self_component_add_port_status bt_component_add_output_port(
                BT_PORT_TYPE_OUTPUT, name, user_data, port);
 }
 
+BT_HIDDEN
+bool bt_component_port_name_is_unique(GPtrArray *ports, const char *name)
+{
+       guint i;
+       bool unique;
+
+       for (i = 0; i < ports->len; i++) {
+               struct bt_port *port = g_ptr_array_index(ports, i);
+
+               if (strcmp(port->name->str, name) == 0) {
+                       unique = false;
+                       goto end;
+               }
+       }
+
+       unique = true;
+
+end:
+       return unique;
+}
+
 BT_HIDDEN
 enum bt_component_class_port_connected_method_status
 bt_component_port_connected(
This page took 0.022733 seconds and 4 git commands to generate.