-
- for (i = 0; i < sequence->len->value._unsigned; i++) {
- struct declaration *elem_type =
- sequence->current_element.declaration;
- elem_type->p.type->copy(dest, fdest, src, fsrc, elem_type);
+ len = sequence->len->value._unsigned;
+ g_array_set_size(sequence->elems, len);
+ /*
+ * Yes, large sequences could be _painfully slow_ to parse due
+ * to memory allocation for each event read. At least, never
+ * shrink the sequence. Note: the sequence GArray len should
+ * never be used as indicator of the current sequence length.
+ * One should always look at the sequence->len->value._unsigned
+ * value for that.
+ */
+ oldlen = sequence->elems->len;
+ if (oldlen < len)
+ g_array_set_size(sequence->elems, len);
+
+ for (i = oldlen; i < len; i++) {
+ struct field *field;
+ GString *str;
+ GQuark name;
+
+ str = g_string_new("");
+ g_string_printf(str, "[%" PRIu64 "]", i);
+ (void) g_string_free(str, TRUE);
+ name = g_quark_from_string(str->str);
+
+ field = &g_array_index(sequence->elems, struct field, i);
+ field->name = name;
+ field->definition = sequence_declaration->elem->definition_new(sequence_declaration->elem,
+ sequence->scope,
+ name, i);
+ field->definition->declaration->copy(dest, fdest, src, fsrc, field->definition);