X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=types%2Fstring.c;h=41ac7576223b919920598d154e0eba64a5c46116;hp=71b9f8232a73e3135551be939e5bc0a731bcd267;hb=d00d17d1e06065eb31a699ce59e16ceb6b858029;hpb=e1151715912eaec959682b3bc10be3ced6abe467 diff --git a/types/string.c b/types/string.c index 71b9f823..41ac7576 100644 --- a/types/string.c +++ b/types/string.c @@ -21,8 +21,9 @@ #include static -struct definition *_string_definition_new(struct type *type, - struct definition_scope *parent_scope); +struct definition *_string_definition_new(struct declaration *declaration, + struct definition_scope *parent_scope, + GQuark field_name, int index); static void _string_definition_free(struct definition *definition); @@ -32,57 +33,59 @@ void string_copy(struct stream_pos *dest, const struct format *fdest, { struct definition_string *string = container_of(definition, struct definition_string, p); - struct type_string *string_type = string->type; + struct declaration_string *string_declaration = string->declaration; if (fsrc->string_copy == fdest->string_copy) { - fsrc->string_copy(dest, src, string_type); + fsrc->string_copy(dest, src, string_declaration); } else { char *tmp = NULL; - fsrc->string_read(&tmp, src, string_type); - fdest->string_write(dest, tmp, string_type); + fsrc->string_read(&tmp, src, string_declaration); + fdest->string_write(dest, tmp, string_declaration); fsrc->string_free_temp(tmp); } } static -void _string_type_free(struct type *type) +void _string_declaration_free(struct declaration *declaration) { - struct type_string *string_type = - container_of(type, struct type_string, p); - g_free(string_type); + struct declaration_string *string_declaration = + container_of(declaration, struct declaration_string, p); + g_free(string_declaration); } -struct type_string *string_type_new(const char *name) +struct declaration_string *string_declaration_new(const char *name) { - struct type_string *string_type; + struct declaration_string *string_declaration; - string_type = g_new(struct type_string, 1); - string_type->p.id = CTF_TYPE_STRING; - string_type->p.name = g_quark_from_string(name); - string_type->p.alignment = CHAR_BIT; - string_type->p.copy = string_copy; - string_type->p.type_free = _string_type_free; - string_type->p.definition_new = _string_definition_new; - string_type->p.definition_free = _string_definition_free; - string_type->p.ref = 1; - return string_type; + string_declaration = g_new(struct declaration_string, 1); + string_declaration->p.id = CTF_TYPE_STRING; + string_declaration->p.name = g_quark_from_string(name); + string_declaration->p.alignment = CHAR_BIT; + string_declaration->p.copy = string_copy; + string_declaration->p.declaration_free = _string_declaration_free; + string_declaration->p.definition_new = _string_definition_new; + string_declaration->p.definition_free = _string_definition_free; + string_declaration->p.ref = 1; + return string_declaration; } static struct definition * - _string_definition_new(struct type *type, - struct definition_scope *parent_scope) + _string_definition_new(struct declaration *declaration, + struct definition_scope *parent_scope, + GQuark field_name, int index) { - struct type_string *string_type = - container_of(type, struct type_string, p); + struct declaration_string *string_declaration = + container_of(declaration, struct declaration_string, p); struct definition_string *string; string = g_new(struct definition_string, 1); - type_ref(&string_type->p); - string->p.type = type; - string->type = string_type; + declaration_ref(&string_declaration->p); + string->p.declaration = declaration; + string->declaration = string_declaration; string->p.ref = 1; + string->p.index = index; string->value = NULL; return &string->p; } @@ -93,7 +96,7 @@ void _string_definition_free(struct definition *definition) struct definition_string *string = container_of(definition, struct definition_string, p); - type_unref(string->p.type); + declaration_unref(string->p.declaration); g_free(string->value); g_free(string); }