[gimp/gimp-2-10] libgimpbase: add gimp_pixpipe_params_free().



commit ee25bfc8bd07362c30320f1dc7e42526291fc9ae
Author: Jehan <jehan girinstud io>
Date:   Wed Jun 27 18:31:38 2018 +0200

    libgimpbase: add gimp_pixpipe_params_free().
    
    And use it where appropriate. A public API asking you to know the
    internals of your code is a bad idea.

 app/core/gimpbrushpipe-load.c |  9 ++++-----
 libgimpbase/gimpparasiteio.c  | 12 ++++++++++++
 libgimpbase/gimpparasiteio.h  |  2 ++
 plug-ins/common/file-gih.c    |  2 ++
 4 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/app/core/gimpbrushpipe-load.c b/app/core/gimpbrushpipe-load.c
index 863e91ea86..818e6088c9 100644
--- a/app/core/gimpbrushpipe-load.c
+++ b/app/core/gimpbrushpipe-load.c
@@ -43,7 +43,6 @@ gimp_brush_pipe_load (GimpContext   *context,
                       GError       **error)
 {
   GimpBrushPipe     *pipe = NULL;
-  GimpPixPipeParams  params;
   gint               i;
   gint               num_of_brushes = 0;
   gint               totalcells;
@@ -125,6 +124,8 @@ gimp_brush_pipe_load (GimpContext   *context,
 
   if (*paramstring)
     {
+      GimpPixPipeParams params;
+
       gimp_pixpipe_params_init (&params);
       gimp_pixpipe_params_parse (paramstring, &params);
 
@@ -132,10 +133,7 @@ gimp_brush_pipe_load (GimpContext   *context,
       pipe->rank      = g_new0 (gint, pipe->dimension);
       pipe->select    = g_new0 (PipeSelectModes, pipe->dimension);
       pipe->index     = g_new0 (gint, pipe->dimension);
-
       /* placement is not used at all ?? */
-      if (params.free_placement_string)
-        g_free (params.placement);
 
       for (i = 0; i < pipe->dimension; i++)
         {
@@ -156,9 +154,10 @@ gimp_brush_pipe_load (GimpContext   *context,
             pipe->select[i] = PIPE_SELECT_TILT_Y;
           else
             pipe->select[i] = PIPE_SELECT_CONSTANT;
-          g_free (params.selection[i]);
           pipe->index[i] = 0;
         }
+
+      gimp_pixpipe_params_free (&params);
     }
   else
     {
diff --git a/libgimpbase/gimpparasiteio.c b/libgimpbase/gimpparasiteio.c
index 1f32a8c3e2..3fbe78be64 100644
--- a/libgimpbase/gimpparasiteio.c
+++ b/libgimpbase/gimpparasiteio.c
@@ -190,3 +190,15 @@ gimp_pixpipe_params_build (GimpPixPipeParams *params)
 
   return g_string_free (str, FALSE);
 }
+
+void
+gimp_pixpipe_params_free (GimpPixPipeParams *params)
+{
+  gint i;
+
+  for (i = 0; i < GIMP_PIXPIPE_MAXDIM; i++)
+    g_free (params->selection[i]);
+
+  if (params->free_placement_string)
+    g_free (params->placement);
+}
diff --git a/libgimpbase/gimpparasiteio.h b/libgimpbase/gimpparasiteio.h
index e1482e4f8b..7a7419c432 100644
--- a/libgimpbase/gimpparasiteio.h
+++ b/libgimpbase/gimpparasiteio.h
@@ -67,6 +67,8 @@ void    gimp_pixpipe_params_parse (const gchar       *parameters,
 /* Build a string representation of GimpPixPipeParams */
 gchar * gimp_pixpipe_params_build (GimpPixPipeParams *params) G_GNUC_MALLOC;
 
+/* Free the internal values. It does not free the struct itsef. */
+void    gimp_pixpipe_params_free  (GimpPixPipeParams *params);
 
 G_END_DECLS
 
diff --git a/plug-ins/common/file-gih.c b/plug-ins/common/file-gih.c
index 5c0250e523..ff6b1c5f7f 100644
--- a/plug-ins/common/file-gih.c
+++ b/plug-ins/common/file-gih.c
@@ -424,6 +424,8 @@ run (const gchar      *name,
             }
         }
 
+      gimp_pixpipe_params_free (&gihparams);
+
       if (export == GIMP_EXPORT_EXPORT)
         gimp_image_delete (image_ID);
     }


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