bt_ctf_field_string_set_value() frees and reallocates a new
g_string object if the value is changed. This change ensures
that the previous string is used if possible.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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;