spa-json: rename _from_string() to _wrap_string() and add new "from" variants

The previous naming convention was confusing because it did not make
it explicit that the string is not being copied. We had this wrong already
in the Lua bindings and thanks to some miracle it hasn't backfired so far
(it was using the "wrap" behaviour with a string that doesn't stay alive).

In some places we actually need the "copy" behaviour and in some other
places we need the "wrap" behaviour, so let's have both variants available.
This commit is contained in:
George Kiagiadakis
2023-11-14 12:36:10 +02:00
parent 96eae7d523
commit 42b64bfc28
11 changed files with 61 additions and 24 deletions

View File

@@ -29,7 +29,7 @@ match_rules_cb (void *data, const char *location, const char *action,
const char *str, size_t len)
{
struct match_rules_cb_data *cb_data = data;
g_autoptr (WpSpaJson) json = wp_spa_json_new_from_stringn (str, len);
g_autoptr (WpSpaJson) json = wp_spa_json_new_wrap_stringn (str, len);
return cb_data->callback (cb_data->data, action, json, cb_data->error) ? 0 : -EPIPE;
}