mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-02 05:43:07 +02:00
Use g_string_free_and_steal () more
Now that there is g_string_free_and_steal (), we can use it instead of the older g_string_free (_, FALSE). Make sure to use its return value while doing so, as opposed to manually accessing string->str, to avoid compiler warnings and make the intent more explicit. This is all done in preparation for making g_string_free (_, FALSE) warn on unused return value much like g_string_free_and_steal (), which will happen in the next commit. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
This commit is contained in:
parent
5e40004bdb
commit
bccff754b6
@ -709,8 +709,8 @@ key_state_serialise (KeyState *state)
|
|||||||
gsize size;
|
gsize size;
|
||||||
gsize i;
|
gsize i;
|
||||||
|
|
||||||
data = state->strinfo->str;
|
|
||||||
size = state->strinfo->len;
|
size = state->strinfo->len;
|
||||||
|
data = g_string_free_and_steal (g_steal_pointer (&state->strinfo));
|
||||||
|
|
||||||
words = data;
|
words = data;
|
||||||
for (i = 0; i < size / sizeof (guint32); i++)
|
for (i = 0; i < size / sizeof (guint32); i++)
|
||||||
@ -720,9 +720,6 @@ key_state_serialise (KeyState *state)
|
|||||||
data, size, TRUE,
|
data, size, TRUE,
|
||||||
g_free, data);
|
g_free, data);
|
||||||
|
|
||||||
g_string_free (state->strinfo, FALSE);
|
|
||||||
state->strinfo = NULL;
|
|
||||||
|
|
||||||
g_variant_builder_add (&builder, "(y@au)",
|
g_variant_builder_add (&builder, "(y@au)",
|
||||||
state->is_flags ? 'f' :
|
state->is_flags ? 'f' :
|
||||||
state->is_enum ? 'e' : 'c',
|
state->is_enum ? 'e' : 'c',
|
||||||
|
@ -3546,10 +3546,7 @@ g_key_file_get_key_comment (GKeyFile *key_file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (string != NULL)
|
if (string != NULL)
|
||||||
{
|
comment = g_string_free_and_steal (g_steal_pointer (&string));
|
||||||
comment = string->str;
|
|
||||||
g_string_free (string, FALSE);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
comment = NULL;
|
comment = NULL;
|
||||||
|
|
||||||
|
@ -83,9 +83,7 @@ subparser_end (GMarkupParseContext *ctx,
|
|||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
string = g_markup_parse_context_pop (ctx);
|
string = g_markup_parse_context_pop (ctx);
|
||||||
result = string->str;
|
result = g_string_free_and_steal (g_steal_pointer (&string));
|
||||||
|
|
||||||
g_string_free (string, FALSE);
|
|
||||||
strings_allocated--;
|
strings_allocated--;
|
||||||
|
|
||||||
if (result == NULL || result[0] == '\0')
|
if (result == NULL || result[0] == '\0')
|
||||||
@ -156,9 +154,7 @@ replay_parser_end (GMarkupParseContext *ctx,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = string->str;
|
result = g_string_free_and_steal (g_steal_pointer (&string));
|
||||||
|
|
||||||
g_string_free (string, FALSE);
|
|
||||||
strings_allocated--;
|
strings_allocated--;
|
||||||
|
|
||||||
if (result == NULL || result[0] == '\0')
|
if (result == NULL || result[0] == '\0')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user