girparser: Use g_clear_pointer() in locate_gir()

This makes the ownership semantics a bit more obvious.

Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie 2023-08-09 11:46:07 +01:00 committed by Simon McVittie
parent 9d8bcc9817
commit 59ae4e65d2

View File

@ -304,8 +304,7 @@ locate_gir (GIrParser *parser,
g_debug ("Trying %s from includes", path); g_debug ("Trying %s from includes", path);
if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
return g_steal_pointer (&path); return g_steal_pointer (&path);
g_free (path); g_clear_pointer (&path, g_free);
path = NULL;
} }
} }
for (dir = datadirs; *dir; dir++) for (dir = datadirs; *dir; dir++)
@ -314,15 +313,14 @@ locate_gir (GIrParser *parser,
g_debug ("Trying %s from system data dirs", path); g_debug ("Trying %s from system data dirs", path);
if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
return g_steal_pointer (&path); return g_steal_pointer (&path);
g_free (path); g_clear_pointer (&path, g_free);
path = NULL;
} }
path = g_build_filename (GIR_DIR, girname, NULL); path = g_build_filename (GIR_DIR, girname, NULL);
g_debug ("Trying %s from GIR_DIR", path); g_debug ("Trying %s from GIR_DIR", path);
if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
return g_steal_pointer (&path); return g_steal_pointer (&path);
g_free (path); g_clear_pointer (&path, g_free);
g_debug ("Did not find %s", girname); g_debug ("Did not find %s", girname);
return NULL; return NULL;