[gegl] memory leaks



commit fb80e6f823c1929c312c1282a84c16773b15add5
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Wed Aug 17 17:26:31 2011 +0200

    memory leaks

 bin/gegl.c                          |    1 +
 gegl/buffer/gegl-buffer-linear.c    |   26 ++++++++++----------------
 gegl/buffer/gegl-buffer.c           |    4 ++++
 gegl/buffer/gegl-sampler-cubic.c    |    9 +++++++++
 gegl/gegl-xml.c                     |    2 +-
 gegl/graph/gegl-node.c              |    2 +-
 gegl/process/gegl-eval-mgr.c        |    2 ++
 operations/affine/affine.c          |   13 +++++++++++--
 operations/common/dropshadow.c      |    4 +++-
 operations/common/fattal02.c        |    4 ++++
 operations/external/matting-levin.c |    1 +
 11 files changed, 47 insertions(+), 21 deletions(-)
---
diff --git a/bin/gegl.c b/bin/gegl.c
index 38cbeb5..5449a28 100644
--- a/bin/gegl.c
+++ b/bin/gegl.c
@@ -251,6 +251,7 @@ main (gint    argc,
         break;
     }
 
+  g_list_free_full (o->files, g_free);
   g_free (o);
   g_object_unref (gegl);
   g_free (script);
diff --git a/gegl/buffer/gegl-buffer-linear.c b/gegl/buffer/gegl-buffer-linear.c
index fa54dca..55475f3 100644
--- a/gegl/buffer/gegl-buffer-linear.c
+++ b/gegl/buffer/gegl-buffer-linear.c
@@ -213,19 +213,19 @@ gegl_buffer_linear_close (GeglBuffer *buffer,
   if (tile)
     {
       gegl_tile_unlock (tile);
+      gegl_tile_unref (tile);
       g_object_set_data (G_OBJECT (buffer), "linear-tile", NULL);
-      tile = NULL;
     }
   else
     {
       GList *linear_buffers;
       GList *iter;
-      BufferInfo *info = NULL;
       linear_buffers = g_object_get_data (G_OBJECT (buffer), "linear-buffers");
 
       for (iter = linear_buffers; iter; iter=iter->next)
         {
-          info = iter->data;
+          BufferInfo *info = iter->data;
+
           if (info->buf == linear)
             {
               info->refs--;
@@ -238,26 +238,20 @@ gegl_buffer_linear_close (GeglBuffer *buffer,
                          */
                 }
 
+              linear_buffers = g_list_remove (linear_buffers, info);
+              g_object_set_data (G_OBJECT (buffer), "linear-buffers", linear_buffers);
+
               g_mutex_unlock (buffer->tile_storage->mutex);
               /* XXX: potential race */
               gegl_buffer_set (buffer, &info->extent, info->format, info->buf, 0);
+
+              gegl_free (info->buf);
+              g_free (info);
+
               g_mutex_lock (buffer->tile_storage->mutex);
               break;
             }
-          else
-            {
-              info = NULL;
-            }
-        }
-
-      if (info)
-        {
-          linear_buffers = g_list_remove (linear_buffers, linear);
-          gegl_free (info->buf);
-          g_free (info);
         }
-
-      g_object_set_data (G_OBJECT (buffer), "linear-buffers", linear_buffers);
     }
   /*gegl_buffer_unlock (buffer);*/
   g_mutex_unlock (buffer->tile_storage->mutex);
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index 08056bb..7c18aef 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -356,6 +356,8 @@ gint gegl_buffer_leaks (void)
         g_printerr ("%s\n", buffer->alloc_stack_trace);
       }
   }
+  g_list_free (allocated_buffers_list);
+  allocated_buffers_list = NULL;
 #endif
 
   return allocated_buffers - de_allocated_buffers;
@@ -395,9 +397,11 @@ static void
 gegl_buffer_finalize (GObject *object)
 {
 #ifdef GEGL_BUFFER_DEBUG_ALLOCATIONS
+  g_free (GEGL_BUFFER (object)->alloc_stack_trace);
   allocated_buffers_list = g_list_remove (allocated_buffers_list, object);
 #endif
 
+  g_free (GEGL_BUFFER (object)->path);
   de_allocated_buffers++;
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
diff --git a/gegl/buffer/gegl-sampler-cubic.c b/gegl/buffer/gegl-sampler-cubic.c
index fe9e32c..684d1f1 100644
--- a/gegl/buffer/gegl-sampler-cubic.c
+++ b/gegl/buffer/gegl-sampler-cubic.c
@@ -36,6 +36,7 @@ enum
   PROP_LAST
 };
 
+static void      gegl_sampler_cubic_finalize (GObject      *gobject);
 static void      gegl_sampler_cubic_get (GeglSampler  *sampler,
                                          gdouble       x,
                                          gdouble       y,
@@ -64,6 +65,7 @@ gegl_sampler_cubic_class_init (GeglSamplerCubicClass *klass)
 
   object_class->set_property = set_property;
   object_class->get_property = get_property;
+  object_class->finalize     = gegl_sampler_cubic_finalize;
 
   sampler_class->get     = gegl_sampler_cubic_get;
 
@@ -95,6 +97,13 @@ gegl_sampler_cubic_class_init (GeglSamplerCubicClass *klass)
 }
 
 static void
+gegl_sampler_cubic_finalize (GObject *object)
+{
+  g_free (GEGL_SAMPLER_CUBIC (object)->type);
+  G_OBJECT_CLASS (gegl_sampler_cubic_parent_class)->finalize (object);
+}
+
+static void
 gegl_sampler_cubic_init (GeglSamplerCubic *self)
 {
  GEGL_SAMPLER (self)->context_rect[0].x = -1;
diff --git a/gegl/gegl-xml.c b/gegl/gegl-xml.c
index 219b9cc..9358cce 100644
--- a/gegl/gegl-xml.c
+++ b/gegl/gegl-xml.c
@@ -509,7 +509,7 @@ static void each_ref (gpointer value,
 
   gegl_node_get (dest_node, "ref", &ref, NULL);
   source_node = g_hash_table_lookup (pd->ids, ref);
-
+  g_free (ref);
   gegl_node_connect_from (dest_node, "input", source_node, "output");
 }
 
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index abe8a25..b4bc98e 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -234,7 +234,7 @@ gegl_node_dispose (GObject *gobject)
 
   {
     gint i;
-    for (i=0; i<4; i++)
+    for (i=0; i<GEGL_MAX_THREADS; i++)
       if (self->priv->eval_mgr[i])
         {
           g_object_unref (self->priv->eval_mgr[i]);
diff --git a/gegl/process/gegl-eval-mgr.c b/gegl/process/gegl-eval-mgr.c
index a315c4f..27da126 100644
--- a/gegl/process/gegl-eval-mgr.c
+++ b/gegl/process/gegl-eval-mgr.c
@@ -88,9 +88,11 @@ gegl_eval_mgr_finalize (GObject *self_object)
 #endif
 
   g_object_unref (self->prepare_visitor);
+  g_object_unref (self->have_visitor);
   g_object_unref (self->eval_visitor);
   g_object_unref (self->need_visitor);
   g_object_unref (self->finish_visitor);
+  g_free (self->pad_name);
 
   G_OBJECT_CLASS (gegl_eval_mgr_parent_class)->finalize (self_object);
 }
diff --git a/operations/affine/affine.c b/operations/affine/affine.c
index b70fe12..aa74c75 100644
--- a/operations/affine/affine.c
+++ b/operations/affine/affine.c
@@ -46,7 +46,7 @@ enum
   PROP_LANCZOS_WIDTH
 };
 
-
+static void          gegl_affine_finalize                  (GObject              *object);
 static void          gegl_affine_get_property              (GObject              *object,
                                                             guint                 prop_id,
                                                             GValue               *value,
@@ -180,6 +180,7 @@ op_affine_class_init (OpAffineClass *klass)
 
   gobject_class->set_property         = gegl_affine_set_property;
   gobject_class->get_property         = gegl_affine_get_property;
+  gobject_class->finalize             = gegl_affine_finalize;
 
   op_class->get_invalidated_by_change = gegl_affine_get_invalidated_by_change;
   op_class->get_bounding_box          = gegl_affine_get_bounding_box;
@@ -233,6 +234,12 @@ op_affine_class_init (OpAffineClass *klass)
                                      G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
 }
 
+static void
+gegl_affine_finalize (GObject *object)
+{
+  g_free (OP_AFFINE (object)->filter);
+  G_OBJECT_CLASS (op_affine_parent_class)->finalize (object);
+}
 
 static void
 op_affine_init (OpAffine *self)
@@ -288,7 +295,7 @@ gegl_affine_set_property (GObject      *object,
       break;
     case PROP_FILTER:
       g_free (self->filter);
-      self->filter = g_strdup (g_value_get_string (value));
+      self->filter = g_value_dup_string (value);
       break;
     case PROP_HARD_EDGES:
       self->hard_edges = g_value_get_boolean (value);
@@ -897,6 +904,7 @@ gegl_affine_process (GeglOperation        *operation,
       src_rect.height -= context_rect.height;
 
       gegl_affine_fast_reflect_x (output, input, result, &src_rect);
+      g_object_unref (sampler);
 
       if (input != NULL)
         g_object_unref (input);
@@ -927,6 +935,7 @@ gegl_affine_process (GeglOperation        *operation,
       src_rect.height -= context_rect.height;
 
       gegl_affine_fast_reflect_y (output, input, result, &src_rect);
+      g_object_unref (sampler);
 
       if (input != NULL)
         g_object_unref (input);
diff --git a/operations/common/dropshadow.c b/operations/common/dropshadow.c
index 7c2e2fc..f62d4b8 100644
--- a/operations/common/dropshadow.c
+++ b/operations/common/dropshadow.c
@@ -42,6 +42,7 @@ static void attach (GeglOperation *operation)
 {
   GeglNode *gegl  = operation->node;
   GeglNode *input, *output, *over, *translate, *opacity, *blur, *darken, *black;
+  GeglColor *black_color = gegl_color_new ("rgb(0.0,0.0,0.0)");
 
   input     = gegl_node_get_input_proxy (gegl, "input");
   output    = gegl_node_get_output_proxy (gegl, "output");
@@ -51,8 +52,9 @@ static void attach (GeglOperation *operation)
   blur      = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL);
   darken    = gegl_node_new_child (gegl, "operation", "gegl:src-in", NULL);
   black     = gegl_node_new_child (gegl, "operation", "gegl:color",
-                                     "value", gegl_color_new ("rgb(0.0,0.0,0.0)"),
+                                     "value", black_color,
                                      NULL);
+  g_object_unref (black_color);
 
   gegl_node_link_many (input, darken, blur, opacity, translate, over, output, NULL);
   gegl_node_connect_from (over, "aux", input, "output");
diff --git a/operations/common/fattal02.c b/operations/common/fattal02.c
index 9f9e9ec..97489ef 100644
--- a/operations/common/fattal02.c
+++ b/operations/common/fattal02.c
@@ -1059,6 +1059,7 @@ fattal02_find_percentiles (const gfloat *array,
 
   *min_value = sorting[(guint)(min_percent * size)];
   *max_value = sorting[(guint)(max_percent * size)];
+  g_free (sorting);
 }
 
 /********************************************************************/
@@ -1292,6 +1293,9 @@ fattal02_process (GeglOperation       *operation,
 
   gegl_buffer_set (output, result, babl_format (OUTPUT_FORMAT), pix,
                    GEGL_AUTO_ROWSTRIDE);
+  g_free (pix);
+  g_free (lum_out);
+  g_free (lum_in);
   return TRUE;
 }
 
diff --git a/operations/external/matting-levin.c b/operations/external/matting-levin.c
index d448897..1eb9e2a 100644
--- a/operations/external/matting-levin.c
+++ b/operations/external/matting-levin.c
@@ -1330,6 +1330,7 @@ matting_solve_level (gdouble             *restrict pixels,
           trimap[i * COMPONENTS_AUX + AUX_VALUE] *= roundf (trimap[i * COMPONENTS_AUX + AUX_VALUE]) *
                                                     trimap[i * COMPONENTS_AUX + AUX_ALPHA];
         }
+      g_free (eroded_alpha);
     }
 
   /* Ordinary solution of the matting laplacian */



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