+ struct declaration_variant *variant_declaration =
+ container_of(declaration, struct declaration_variant, p);
+
+ bt_declaration_unref(&variant_declaration->untagged_variant->p);
+ g_array_free(variant_declaration->tag_name, TRUE);
+ g_free(variant_declaration);
+}
+
+struct declaration_variant *
+ bt_variant_declaration_new(struct declaration_untagged_variant *untagged_variant, const char *tag)
+{
+ struct declaration_variant *variant_declaration;
+ struct bt_declaration *declaration;
+
+ variant_declaration = g_new(struct declaration_variant, 1);
+ declaration = &variant_declaration->p;
+ variant_declaration->untagged_variant = untagged_variant;
+ bt_declaration_ref(&untagged_variant->p);
+ variant_declaration->tag_name = g_array_new(FALSE, TRUE, sizeof(GQuark));
+ bt_append_scope_path(tag, variant_declaration->tag_name);
+ declaration->id = CTF_TYPE_VARIANT;
+ declaration->alignment = 1;
+ declaration->declaration_free = _variant_declaration_free;
+ declaration->definition_new = _variant_definition_new;
+ declaration->definition_free = _variant_definition_free;
+ declaration->ref = 1;
+ return variant_declaration;
+}
+
+static
+struct bt_definition *
+ _variant_definition_new(struct bt_declaration *declaration,
+ struct definition_scope *parent_scope,
+ GQuark field_name, int index,
+ const char *root_name)
+{
+ struct declaration_variant *variant_declaration =
+ container_of(declaration, struct declaration_variant, p);
+ struct definition_variant *variant;