+ if (integer_declaration->encoding == CTF_STRING_UTF8
+ || integer_declaration->encoding == CTF_STRING_ASCII) {
+
+ array->string = g_string_new("");
+
+ if (integer_declaration->len == CHAR_BIT
+ && integer_declaration->p.alignment == CHAR_BIT) {
+ return &array->p;
+ }
+ }
+ }
+
+ array->elems = g_ptr_array_sized_new(array_declaration->len);
+ g_ptr_array_set_size(array->elems, array_declaration->len);
+ for (i = 0; i < array_declaration->len; i++) {
+ struct bt_definition **field;
+ GString *str;
+ GQuark name;
+
+ str = g_string_new("");
+ g_string_printf(str, "[%u]", (unsigned int) i);
+ name = g_quark_from_string(str->str);
+ (void) g_string_free(str, TRUE);
+
+ field = (struct bt_definition **) &g_ptr_array_index(array->elems, i);
+ *field = array_declaration->elem->definition_new(array_declaration->elem,
+ array->p.scope,
+ name, i, NULL);
+ if (!*field)
+ goto error;
+ }
+
+ return &array->p;
+
+error:
+ for (i--; i >= 0; i--) {
+ struct bt_definition *field;
+
+ field = g_ptr_array_index(array->elems, i);
+ field->declaration->definition_free(field);
+ }
+ (void) g_ptr_array_free(array->elems, TRUE);
+ bt_free_definition_scope(array->p.scope);
+ bt_declaration_unref(array->p.declaration);
+ g_free(array);
+ return NULL;
+}
+
+static
+void _array_definition_free(struct bt_definition *definition)
+{
+ struct definition_array *array =
+ container_of(definition, struct definition_array, p);
+ uint64_t i;
+
+ if (array->string)
+ (void) g_string_free(array->string, TRUE);
+ if (array->elems) {
+ for (i = 0; i < array->elems->len; i++) {
+ struct bt_definition *field;
+
+ field = g_ptr_array_index(array->elems, i);
+ field->declaration->definition_free(field);
+ }
+ (void) g_ptr_array_free(array->elems, TRUE);