[libchamplain] Lots of leaks found and fixed



commit 89b79be10f182f02b76b7e72405b37accffd0397
Author: JiÅ?í Techet <techet gmail com>
Date:   Fri Aug 20 16:03:48 2010 +0200

    Lots of leaks found and fixed
    
    Thanks, Valgrind...
    
    Signed-off-by: JiÅ?í Techet <techet gmail com>

 champlain/champlain-file-cache.c          |    8 +++++++-
 champlain/champlain-memory-cache.c        |    3 +++
 champlain/champlain-network-tile-source.c |    3 ++-
 champlain/champlain-polygon.c             |    5 +++++
 champlain/champlain-view.c                |   16 ++++++++++------
 5 files changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/champlain/champlain-file-cache.c b/champlain/champlain-file-cache.c
index b7af70e..f179afa 100644
--- a/champlain/champlain-file-cache.c
+++ b/champlain/champlain-file-cache.c
@@ -640,7 +640,11 @@ file_loaded_cb (GFile *file,
 
   if (!ok)
     {
-      DEBUG ("Failed to load tile %s, error: %s", g_file_get_path(file), error->message);
+      gchar *path;
+
+      path = g_file_get_path(file);
+      DEBUG ("Failed to load tile %s, error: %s", path, error->message);
+      g_free (path);
       contents = NULL;
       length = 0;
       g_error_free (error);
@@ -680,6 +684,7 @@ fill_tile (ChamplainMapSource *map_source,
 
       filename = get_filename (CHAMPLAIN_FILE_CACHE (map_source), tile);
       file = g_file_new_for_path (filename);
+      g_free (filename);
 
       user_data = g_slice_new (FileLoadedData);
       user_data->tile = tile;
@@ -859,6 +864,7 @@ on_tile_filled (ChamplainTileCache *tile_cache,
     }
 
 call_next:
+  g_free (filename);
   if (CHAMPLAIN_IS_TILE_CACHE (next_source))
     champlain_tile_cache_on_tile_filled (CHAMPLAIN_TILE_CACHE (next_source), tile);
 }
diff --git a/champlain/champlain-memory-cache.c b/champlain/champlain-memory-cache.c
index 020da91..fa81d68 100644
--- a/champlain/champlain-memory-cache.c
+++ b/champlain/champlain-memory-cache.c
@@ -114,6 +114,7 @@ champlain_memory_cache_finalize (GObject *object)
 {
   ChamplainMemoryCache *memory_cache = CHAMPLAIN_MEMORY_CACHE (object);
 
+  champlain_memory_cache_clean (memory_cache);
   g_queue_free (memory_cache->priv->queue);
 
   G_OBJECT_CLASS (champlain_memory_cache_parent_class)->finalize (object);
@@ -304,6 +305,7 @@ fill_tile (ChamplainMapSource *map_source,
 
       key.key = generate_queue_key (memory_cache, tile);
       link = g_queue_find_custom (priv->queue, &key, (GCompareFunc) compare_queue_members);
+      g_free (key.key);
       if (link)
         {
           QueueMember *member = link->data;
@@ -419,6 +421,7 @@ on_tile_filled (ChamplainTileCache *tile_cache,
 
   key.key = generate_queue_key (memory_cache, tile);
   link = g_queue_find_custom (priv->queue, &key, (GCompareFunc) compare_queue_members);
+  g_free (key.key);
   if (link)
     move_queue_member_to_head (priv->queue, link);
 
diff --git a/champlain/champlain-network-tile-source.c b/champlain/champlain-network-tile-source.c
index 033ba06..6bdb787 100644
--- a/champlain/champlain-network-tile-source.c
+++ b/champlain/champlain-network-tile-source.c
@@ -177,6 +177,7 @@ champlain_network_tile_source_dispose (GObject *object)
   if (priv->soup_session)
     {
       soup_session_abort (priv->soup_session);
+      g_object_unref (priv->soup_session);
       priv->soup_session = NULL;
     }
 
@@ -722,8 +723,8 @@ fill_tile (ChamplainMapSource *map_source,
           champlain_tile_get_x (tile),
           champlain_tile_get_y (tile),
           champlain_tile_get_zoom_level (tile));
-
       msg = soup_message_new (SOUP_METHOD_GET, uri);
+      g_free (uri);
 
       if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_LOADED)
         {
diff --git a/champlain/champlain-polygon.c b/champlain/champlain-polygon.c
index 379d78d..9bc7ad2 100644
--- a/champlain/champlain-polygon.c
+++ b/champlain/champlain-polygon.c
@@ -183,8 +183,13 @@ champlain_polygon_dispose (GObject *object)
 static void
 champlain_polygon_finalize (GObject *object)
 {
+  ChamplainPolygonPrivate *priv = CHAMPLAIN_POLYGON (object)->priv;
+
   champlain_polygon_clear_points (CHAMPLAIN_POLYGON (object));
 
+  clutter_color_free (priv->stroke_color);
+  clutter_color_free (priv->fill_color);
+
   G_OBJECT_CLASS (champlain_polygon_parent_class)->finalize (object);
 }
 
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index c077677..02877d0 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -873,6 +873,10 @@ champlain_view_finalize (GObject *object)
 {
   DEBUG_LOG ()
 
+  ChamplainViewPrivate *priv = CHAMPLAIN_VIEW (object)->priv;
+
+  g_free (priv->license_text);
+
   G_OBJECT_CLASS (champlain_view_parent_class)->finalize (object);
 }
 
@@ -2492,7 +2496,7 @@ view_load_visible_tiles (ChamplainView *view)
   ChamplainViewPrivate *priv = view->priv;
   ChamplainRectangle viewport = priv->viewport_size;
   gint size;
-  GList *children;
+  GList *children, *child;
   gint x_count, y_count, x_first, y_first, x_end, y_end, max_x_end, max_y_end;
   gboolean *tile_map;
   gint arm_size, arm_max, turn;
@@ -2539,9 +2543,9 @@ view_load_visible_tiles (ChamplainView *view)
 
   /* Get rid of old tiles first */
   children = clutter_container_get_children (CLUTTER_CONTAINER (priv->map_layer));
-  for (; children != NULL; children = g_list_next (children))
+  for (child = children; child != NULL; child = g_list_next (child))
     {
-      ChamplainTile *tile = CHAMPLAIN_TILE (children->data);
+      ChamplainTile *tile = CHAMPLAIN_TILE (child->data);
 
       gint tile_x = champlain_tile_get_x (tile);
       gint tile_y = champlain_tile_get_y (tile);
@@ -2665,12 +2669,12 @@ remove_all_tiles (ChamplainView *view)
   DEBUG_LOG ()
 
   ChamplainViewPrivate *priv = view->priv;
-  GList *children;
+  GList *children, *child;
 
   children = clutter_container_get_children (CLUTTER_CONTAINER (priv->map_layer));
-  for (; children != NULL; children = g_list_next (children))
+  for (child = children; child != NULL; child = g_list_next (child))
     {
-      ChamplainTile *tile = CHAMPLAIN_TILE (children->data);
+      ChamplainTile *tile = CHAMPLAIN_TILE (child->data);
 
       champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
       clutter_container_remove_actor (CLUTTER_CONTAINER (priv->map_layer), CLUTTER_ACTOR (tile));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]