Add internal BT_ASSERT() and BT_ASSERT_PRE() helpers
[babeltrace.git] / lib / ctf-ir / field-types.c
index 62f2412b5b81bc4ab99296d71eb49198395d762c..ba288b2ebc9ab04aaa158bf82bedb5d4c3f527ee 100644 (file)
@@ -2006,6 +2006,35 @@ error:
        return NULL;
 }
 
+BT_HIDDEN
+int bt_field_type_structure_replace_field(struct bt_field_type *type,
+               const char *field_name, struct bt_field_type *field_type)
+{
+       int ret = 0;
+       struct bt_field_type_structure *structure;
+       GQuark name_quark;
+       uint64_t i;
+
+       assert(type);
+       assert(field_name);
+       assert(field_type);
+       assert(type->id == BT_FIELD_TYPE_ID_STRUCT);
+       structure = container_of(type, struct bt_field_type_structure, parent);
+       name_quark = g_quark_from_string(field_name);
+
+       for (i = 0; i < structure->fields->len; i++) {
+               struct structure_field *field = g_ptr_array_index(
+                       structure->fields, i);
+
+               if (field->name == name_quark) {
+                       bt_put(field->type);
+                       field->type = bt_get(field_type);
+               }
+       }
+
+       return ret;
+}
+
 int bt_field_type_structure_add_field(struct bt_field_type *type,
                struct bt_field_type *field_type,
                const char *field_name)
This page took 0.028878 seconds and 4 git commands to generate.