mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-31 04:43:06 +02:00
guri: Simplify memory management in parse_host()
This introduces no functional changes, but makes the memory ownership a little clearer and reduces the length of the code. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
58fce4b92b
commit
17a53f2fc7
18
glib/guri.c
18
glib/guri.c
@ -511,7 +511,7 @@ parse_host (const gchar *start,
|
|||||||
gchar **out,
|
gchar **out,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar *decoded, *host;
|
gchar *decoded = NULL, *host;
|
||||||
gchar *addr = NULL;
|
gchar *addr = NULL;
|
||||||
|
|
||||||
if (*start == '[')
|
if (*start == '[')
|
||||||
@ -537,7 +537,7 @@ parse_host (const gchar *start,
|
|||||||
if (!uri_normalize (&decoded, start, length, flags,
|
if (!uri_normalize (&decoded, start, length, flags,
|
||||||
G_URI_ERROR_BAD_HOST, error))
|
G_URI_ERROR_BAD_HOST, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
host = decoded;
|
host = g_steal_pointer (&decoded);
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,18 +559,16 @@ parse_host (const gchar *start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g_hostname_is_non_ascii (decoded))
|
if (g_hostname_is_non_ascii (decoded))
|
||||||
{
|
host = g_hostname_to_ascii (decoded);
|
||||||
host = g_hostname_to_ascii (decoded);
|
|
||||||
g_free (decoded);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
host = decoded;
|
host = g_steal_pointer (&decoded);
|
||||||
|
|
||||||
ok:
|
ok:
|
||||||
if (out)
|
if (out)
|
||||||
*out = host;
|
*out = g_steal_pointer (&host);
|
||||||
else
|
g_free (host);
|
||||||
g_free (host);
|
g_free (decoded);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user