- struct type_class_struct *struct_class;
- struct type_class *type_class;
- int ret;
-
- struct_class = g_new(struct type_class_struct, 1);
- type_class = &struct_class->p;
- struct_class->fields_by_name = g_hash_table_new(g_direct_hash,
- g_direct_equal);
- struct_class->fields = g_array_sized_new(FALSE, TRUE,
- sizeof(struct type_class_field),
- DEFAULT_NR_STRUCT_FIELDS);
- type_class->name = g_quark_from_string(name);
- type_class->alignment = 1;
- type_class->copy = struct_copy;
- type_class->class_free = _struct_type_class_free;
- type_class->type_new = _struct_type_new;
- type_class->type_free = _struct_type_free;
- type_class->ref = 1;
-
- if (type_class->name) {
- ret = register_type(type_class);
- if (ret)
- goto error_register;
- }
- return struct_class;
-
-error_register:
- g_hash_table_destroy(struct_class->fields_by_name);
- g_array_free(struct_class->fields, true);
- g_free(struct_class);
- return NULL;
+ struct declaration_struct *struct_declaration;
+ struct declaration *declaration;
+
+ struct_declaration = g_new(struct declaration_struct, 1);
+ declaration = &struct_declaration->p;
+ struct_declaration->fields_by_name = g_hash_table_new(g_direct_hash,
+ g_direct_equal);
+ struct_declaration->fields = g_array_sized_new(FALSE, TRUE,
+ sizeof(struct declaration_field),
+ DEFAULT_NR_STRUCT_FIELDS);
+ struct_declaration->scope = new_declaration_scope(parent_scope);
+ declaration->id = CTF_TYPE_STRUCT;
+ declaration->alignment = 1;
+ declaration->copy = struct_copy;
+ declaration->declaration_free = _struct_declaration_free;
+ declaration->definition_new = _struct_definition_new;
+ declaration->definition_free = _struct_definition_free;
+ declaration->ref = 1;
+ return struct_declaration;