Reuse previously allocated string when setting value
[babeltrace.git] / formats / ctf / ir / event-fields.c
index 17c597ac183d5d70e1a6682797ac1a1414f6e656..ed2cf489fc4e82b535c27885793afe8ecb30ee57 100644 (file)
@@ -851,10 +851,11 @@ int bt_ctf_field_string_set_value(struct bt_ctf_field *field,
 
        string = container_of(field, struct bt_ctf_field_string, parent);
        if (string->payload) {
-               g_string_free(string->payload, TRUE);
+               g_string_assign(string->payload, value);
+       } else {
+               string->payload = g_string_new(value);
        }
 
-       string->payload = g_string_new(value);
        string->parent.payload_set = 1;
 end:
        return ret;
This page took 0.023964 seconds and 4 git commands to generate.