[gnome-shell] StTextureCache: Fix leak of key string
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] StTextureCache: Fix leak of key string
- Date: Tue, 24 May 2011 17:11:45 +0000 (UTC)
commit fdefb317cbdfbed72a8e52594ce00fd4171a803e
Author: Colin Walters <walters verbum org>
Date: Tue May 24 12:51:47 2011 -0400
StTextureCache: Fix leak of key string
Also micro-optimize by avoiding another strdup(), instead pass
ownership of the string when we can.
https://bugzilla.gnome.org/show_bug.cgi?id=649508
src/st/st-texture-cache.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index fba794a..24471bc 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -1154,7 +1154,6 @@ create_texture_and_ensure_request (StTextureCache *cache,
{
/* Not cached and no pending request, create it */
*request = g_new0 (AsyncTextureLoadData, 1);
- (*request)->key = g_strdup (key);
g_hash_table_insert (cache->priv->outstanding_requests, g_strdup (key), *request);
}
else
@@ -1209,9 +1208,10 @@ load_gicon_with_colors (StTextureCache *cache,
info = gtk_icon_theme_lookup_by_gicon (theme, icon, size, GTK_ICON_LOOKUP_USE_BUILTIN);
if (info != NULL)
{
+ /* Transfer ownership of key */
+ request->key = key;
/* hardcoded here for now; we should actually blow this away on
* icon theme changes probably */
- request->key = g_strdup (key);
request->policy = ST_TEXTURE_CACHE_POLICY_FOREVER;
request->icon = g_object_ref (icon);
request->icon_info = info;
@@ -1227,14 +1227,13 @@ load_gicon_with_colors (StTextureCache *cache,
*/
g_slist_foreach (request->textures, (GFunc) g_object_unref, NULL);
g_slist_free (request->textures);
- g_free (request->key);
g_free (request);
g_hash_table_remove (cache->priv->outstanding_requests, key);
+ g_free (key);
g_object_unref (texture);
texture = NULL;
}
- g_free (key);
return CLUTTER_ACTOR (texture);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]