Fix integer/float/string read: keep value in definition structure
[babeltrace.git] / types / string.c
index 41ac7576223b919920598d154e0eba64a5c46116..6e5c6f472b41d115181e05c57962a3c9f8676476 100644 (file)
@@ -35,15 +35,11 @@ void string_copy(struct stream_pos *dest, const struct format *fdest,
                container_of(definition, struct definition_string, p);
        struct declaration_string *string_declaration = string->declaration;
 
-       if (fsrc->string_copy == fdest->string_copy) {
-               fsrc->string_copy(dest, src, string_declaration);
-       } else {
-               char *tmp = NULL;
-
-               fsrc->string_read(&tmp, src, string_declaration);
-               fdest->string_write(dest, tmp, string_declaration);
-               fsrc->string_free_temp(tmp);
-       }
+       g_free(string->value);
+       string->value = NULL;
+       fsrc->string_read(&string->value, src, string_declaration);
+       if (fdest)
+               fdest->string_write(dest, string->value, string_declaration);
 }
 
 static
@@ -54,19 +50,20 @@ void _string_declaration_free(struct declaration *declaration)
        g_free(string_declaration);
 }
 
-struct declaration_string *string_declaration_new(const char *name)
+struct declaration_string *
+       string_declaration_new(enum ctf_string_encoding encoding)
 {
        struct declaration_string *string_declaration;
 
        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;
+       string_declaration->encoding = encoding;
        return string_declaration;
 }
 
This page took 0.0232 seconds and 4 git commands to generate.