mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 11:26:16 +01:00
gresource: Improve resource unregistration performance slightly
Rather than iterating over the list twice: once to find the resource, and once to re-find its link and delete it, just use `g_list_delete_link()` to delete what was found. This has the lovely side-effect of squashing a false positive from scan-build, which thought there was a use-after-free of `resource` in the caller, due to `g_resource_unref()` being called on it here. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #1767
This commit is contained in:
parent
1ed199a881
commit
ae3bd19108
@ -1029,14 +1029,16 @@ g_resources_register_unlocked (GResource *resource)
|
|||||||
static void
|
static void
|
||||||
g_resources_unregister_unlocked (GResource *resource)
|
g_resources_unregister_unlocked (GResource *resource)
|
||||||
{
|
{
|
||||||
if (g_list_find (registered_resources, resource) == NULL)
|
GList *resource_link = g_list_find (registered_resources, resource);
|
||||||
|
|
||||||
|
if (resource_link == NULL)
|
||||||
{
|
{
|
||||||
g_warning ("Tried to remove not registered resource");
|
g_warning ("Tried to remove not registered resource");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
registered_resources = g_list_remove (registered_resources, resource);
|
g_resource_unref (resource_link->data);
|
||||||
g_resource_unref (resource);
|
registered_resources = g_list_delete_link (registered_resources, resource_link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user