+
+static
+void generic_field_freeze(struct bt_ctf_field *field)
+{
+ field->frozen = 1;
+}
+
+static
+void bt_ctf_field_enumeration_freeze(struct bt_ctf_field *field)
+{
+ struct bt_ctf_field_enumeration *enum_field =
+ container_of(field, struct bt_ctf_field_enumeration, parent);
+
+ bt_ctf_field_freeze(enum_field->payload);
+ generic_field_freeze(field);
+}
+
+static
+void bt_ctf_field_structure_freeze(struct bt_ctf_field *field)
+{
+ int i;
+ struct bt_ctf_field_structure *structure_field =
+ container_of(field, struct bt_ctf_field_structure, parent);
+
+ for (i = 0; i < structure_field->fields->len; i++) {
+ struct bt_ctf_field *field =
+ g_ptr_array_index(structure_field->fields, i);
+
+ bt_ctf_field_freeze(field);
+ }
+
+ generic_field_freeze(field);
+}
+
+static
+void bt_ctf_field_variant_freeze(struct bt_ctf_field *field)
+{
+ struct bt_ctf_field_variant *variant_field =
+ container_of(field, struct bt_ctf_field_variant, parent);
+
+ bt_ctf_field_freeze(variant_field->tag);
+ bt_ctf_field_freeze(variant_field->payload);
+ generic_field_freeze(field);
+}
+
+static
+void bt_ctf_field_array_freeze(struct bt_ctf_field *field)
+{
+ int i;
+ struct bt_ctf_field_array *array_field =
+ container_of(field, struct bt_ctf_field_array, parent);
+
+ for (i = 0; i < array_field->elements->len; i++) {
+ struct bt_ctf_field *field =
+ g_ptr_array_index(array_field->elements, i);
+
+ bt_ctf_field_freeze(field);
+ }
+
+ generic_field_freeze(field);
+}
+
+static
+void bt_ctf_field_sequence_freeze(struct bt_ctf_field *field)
+{
+ int i;
+ struct bt_ctf_field_sequence *sequence_field =
+ container_of(field, struct bt_ctf_field_sequence, parent);
+
+ bt_ctf_field_freeze(sequence_field->length);
+
+ for (i = 0; i < sequence_field->elements->len; i++) {
+ struct bt_ctf_field *field =
+ g_ptr_array_index(sequence_field->elements, i);
+
+ bt_ctf_field_freeze(field);
+ }
+
+ generic_field_freeze(field);
+}
+
+BT_HIDDEN
+void bt_ctf_field_freeze(struct bt_ctf_field *field)
+{
+ enum bt_ctf_type_id type_id;
+
+ if (!field) {
+ goto end;
+ }
+
+ type_id = bt_ctf_field_get_type_id(field);
+ if (type_id <= BT_CTF_TYPE_ID_UNKNOWN ||
+ type_id >= BT_CTF_NR_TYPE_IDS) {
+ goto end;
+ }
+
+ field_freeze_funcs[type_id](field);
+end:
+ return;
+}