X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=types%2Fstring.c;fp=types%2Fstring.c;h=47e0970e890280b159d52d385a15cc0e60eed63b;hp=0f261f418b1bd2a766dcba83bd2bd0e8d8ce1f4a;hb=98df1c9fb24d5e7e10bf628692011e130e0d8339;hpb=2527e1494b783a60d8a874f28835700046f55dda diff --git a/types/string.c b/types/string.c index 0f261f41..47e0970e 100644 --- a/types/string.c +++ b/types/string.c @@ -23,7 +23,8 @@ static struct definition *_string_definition_new(struct declaration *declaration, struct definition_scope *parent_scope, - GQuark field_name, int index); + GQuark field_name, int index, + const char *root_name); static void _string_definition_free(struct definition *definition); @@ -55,23 +56,33 @@ static struct definition * _string_definition_new(struct declaration *declaration, struct definition_scope *parent_scope, - GQuark field_name, int index) + GQuark field_name, int index, + const char *root_name) { struct declaration_string *string_declaration = container_of(declaration, struct declaration_string, p); struct definition_string *string; + int ret; string = g_new(struct definition_string, 1); declaration_ref(&string_declaration->p); string->p.declaration = declaration; string->declaration = string_declaration; string->p.ref = 1; - string->p.index = index; + /* + * Use INT_MAX order to ensure that all fields of the parent + * scope are seen as being prior to this scope. + */ + string->p.index = root_name ? INT_MAX : index; string->p.name = field_name; - string->p.path = new_definition_path(parent_scope, field_name); + string->p.path = new_definition_path(parent_scope, field_name, + root_name); string->value = NULL; string->len = 0; string->alloc_len = 0; + ret = register_field_definition(field_name, &string->p, + parent_scope); + assert(!ret); return &string->p; }