lib: have dedicated "dynamic array FC with/without length field" types
[babeltrace.git] / src / lib / trace-ir / field-class.c
index f02ce45c45f2b98bc273ab84e2cd638772003a55..25d5b7e718e964daa73134d00a5ad0a7f8c13bd0 100644 (file)
@@ -1498,6 +1498,8 @@ struct bt_field_class *bt_field_class_variant_create(
                bt_object_get_ref_no_null_check(var_with_sel_fc->selector_fc);
                bt_field_class_freeze(selector_fc);
                var_fc = (void *) var_with_sel_fc;
+               BT_LIB_LOGD("Created default variant field class with selector object: "
+                       "%![var-fc-]+F, %![sel-fc-]+F", var_fc, selector_fc);
        } else {
                var_fc = g_new0(struct bt_field_class_variant, 1);
                if (!var_fc) {
@@ -1513,15 +1515,16 @@ struct bt_field_class *bt_field_class_variant_create(
                        /* init_named_field_classes_container() logs errors */
                        goto error;
                }
+               BT_LIB_LOGD("Created default variant field class without selector object: "
+                       "%![var-fc-]+F", var_fc);
        }
 
        BT_ASSERT(var_fc);
-       BT_LIB_LOGD("Created default variant field class with selector object: "
-               "%![var-fc-]+F, %![sel-fc-]+F", var_fc, selector_fc);
        goto end;
 
 error:
        BT_OBJECT_PUT_REF_AND_RESET(var_fc);
+       BT_OBJECT_PUT_REF_AND_RESET(var_with_sel_fc);
 
 end:
        return (void *) var_fc;
@@ -2024,7 +2027,9 @@ struct bt_field_class *bt_field_class_array_dynamic_create(
        }
 
        if (init_array_field_class((void *) array_fc,
-                       BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
+                       length_fc ?
+                               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD :
+                               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
                        destroy_dynamic_array_field_class, element_fc)) {
                goto error;
        }
@@ -2048,13 +2053,14 @@ end:
 }
 
 const struct bt_field_path *
-bt_field_class_array_dynamic_borrow_length_field_path_const(
+bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
                const struct bt_field_class *fc)
 {
        const struct bt_field_class_array_dynamic *seq_fc = (const void *) fc;
 
        BT_ASSERT_PRE_DEV_NON_NULL(fc, "Field class");
-       BT_ASSERT_PRE_DEV_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
+       BT_ASSERT_PRE_DEV_FC_HAS_ID(fc,
+               BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
                "Field class");
        return seq_fc->length_field_path;
 }
@@ -2172,7 +2178,8 @@ void bt_field_class_make_part_of_trace_class(const struct bt_field_class *c_fc)
                break;
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
-       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
        {
                struct bt_field_class_array *array_fc = (void *) fc;
 
This page took 0.024752 seconds and 4 git commands to generate.