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.

(cherry picked from commit ee25bfc8bd)
This commit is contained in:
Jehan 2018-06-27 18:31:38 +02:00
parent 47163717ba
commit 779de4bcf8
4 changed files with 20 additions and 5 deletions

View File

@ -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
{

View File

@ -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);
}

View File

@ -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

View File

@ -424,6 +424,8 @@ run (const gchar *name,
}
}
gimp_pixpipe_params_free (&gihparams);
if (export == GIMP_EXPORT_EXPORT)
gimp_image_delete (image_ID);
}