[Spice-commits] 2 commits - src/channel-cursor.c src/channel-display.c src/spice-channel-cache.h src/spice-session.c

Christophe Fergau teuf at kemper.freedesktop.org
Wed Oct 14 01:10:26 PDT 2015


 src/channel-cursor.c      |    2 +-
 src/channel-display.c     |    2 +-
 src/spice-channel-cache.h |    3 ++-
 src/spice-session.c       |    2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 93182f22a9b807a3ee5d663f7ff7b9fb0ce215a1
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Oct 12 15:36:58 2015 +0200

    Free display_cache in cache_unref
    
    Otherwise it will be leaked. There is no cache_ref function, or helper
    increasing a refcount/taking a reference so cache_unref really is a
    cache_free method.
    
    This fixes:
    
    ==27687== 64 bytes in 4 blocks are definitely lost in loss record 250 of 435
    ==27687==    at 0x4C28C50: malloc (vg_replace_malloc.c:299)
    ==27687==    by 0xA6AF058: g_malloc (gmem.c:94)
    ==27687==    by 0xA6C5982: g_slice_alloc (gslice.c:1007)
    ==27687==    by 0x40F112: cache_new (spice-channel-cache.h:54)
    ==27687==    by 0x40F112: cache_image_new (spice-channel-cache.h:64)
    ==27687==    by 0x40F112: spice_session_init (spice-session.c:294)
    ==27687==    by 0xA239B4A: g_type_create_instance (gtype.c:1870)
    ==27687==    by 0xA21C31A: g_object_new_internal (gobject.c:1779)
    ==27687==    by 0xA21DB10: g_object_newv (gobject.c:1926)
    ==27687==    by 0xA21E3FB: g_object_new (gobject.c:1619)
    ==27687==    by 0x40FF4D: spice_session_new (spice-session.c:1479)
    ==27687==    by 0x40E678: test_session_uri (session.c:35)
    ==27687==    by 0xA6CE47A: test_case_run (gtestutils.c:2158)
    ==27687==    by 0xA6CE47A: g_test_run_suite_internal (gtestutils.c:2241)
    ==27687==    by 0xA6CE642: g_test_run_suite_internal (gtestutils.c:2253)

diff --git a/src/spice-channel-cache.h b/src/spice-channel-cache.h
index 238ceb7..e609a67 100644
--- a/src/spice-channel-cache.h
+++ b/src/spice-channel-cache.h
@@ -131,6 +131,7 @@ static inline void cache_clear(display_cache *cache)
 static inline void cache_free(display_cache *cache)
 {
     g_hash_table_unref(cache->table);
+    g_slice_free(display_cache, cache);
 }
 
 G_END_DECLS
commit 13662bb367692817f88f1116476197fe32defac6
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Oct 12 16:31:50 2015 +0200

    Rename display_cache::cache_unref to cache_free
    
    display_cache is no longer refcounted since commit c9d4773, but this is
    not an issue as even before, the fact that it was refcounted was not
    used as there was no corresponding cache_ref() call (and
    g_hash_table_ref() was not called directly either).
    As the next commit will free memory from cache_unref() rather than just
    releasing a reference, it's better to make it obvious that this method
    is a _free() method rather than an _unref() one.

diff --git a/src/channel-cursor.c b/src/channel-cursor.c
index 6a9d60a..0765209 100644
--- a/src/channel-cursor.c
+++ b/src/channel-cursor.c
@@ -91,7 +91,7 @@ static void spice_cursor_channel_finalize(GObject *obj)
     SpiceCursorChannel *channel = SPICE_CURSOR_CHANNEL(obj);
     SpiceCursorChannelPrivate *c = channel->priv;
 
-    g_clear_pointer(&c->cursors, cache_unref);
+    g_clear_pointer(&c->cursors, cache_free);
 
     if (G_OBJECT_CLASS(spice_cursor_channel_parent_class)->finalize)
         G_OBJECT_CLASS(spice_cursor_channel_parent_class)->finalize(obj);
diff --git a/src/channel-display.c b/src/channel-display.c
index 9f9d62a..46e9829 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -142,7 +142,7 @@ static void spice_display_channel_finalize(GObject *object)
     clear_surfaces(SPICE_CHANNEL(object), FALSE);
     g_hash_table_unref(c->surfaces);
     clear_streams(SPICE_CHANNEL(object));
-    g_clear_pointer(&c->palettes, cache_unref);
+    g_clear_pointer(&c->palettes, cache_free);
 
     if (G_OBJECT_CLASS(spice_display_channel_parent_class)->finalize)
         G_OBJECT_CLASS(spice_display_channel_parent_class)->finalize(object);
diff --git a/src/spice-channel-cache.h b/src/spice-channel-cache.h
index 6e2d084..238ceb7 100644
--- a/src/spice-channel-cache.h
+++ b/src/spice-channel-cache.h
@@ -128,7 +128,7 @@ static inline void cache_clear(display_cache *cache)
     g_hash_table_remove_all(cache->table);
 }
 
-static inline void cache_unref(display_cache *cache)
+static inline void cache_free(display_cache *cache)
 {
     g_hash_table_unref(cache->table);
 }
diff --git a/src/spice-session.c b/src/spice-session.c
index 85640a5..c673fa2 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -372,7 +372,7 @@ spice_session_finalize(GObject *gobject)
     g_strfreev(s->secure_channels);
     g_free(s->shared_dir);
 
-    g_clear_pointer(&s->images, cache_unref);
+    g_clear_pointer(&s->images, cache_free);
     glz_decoder_window_destroy(s->glz_window);
 
     g_clear_pointer(&s->pubkey, g_byte_array_unref);


More information about the Spice-commits mailing list