Commit e61b1f76 authored by Michael Natterer's avatar Michael Natterer 😴

pdb: return NULL terminated stringarrays from libgimp PDB wrappers

so they can be freed with g_strfreev().
parent d8456b5d
......@@ -217,9 +217,10 @@ gimp_get_parasite_list (gint *num_parasites)
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_parasites = return_vals[1].data.d_int32;
parasites = g_new (gchar *, *num_parasites);
parasites = g_new (gchar *, *num_parasites + 1);
for (i = 0; i < *num_parasites; i++)
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
parasites[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -96,9 +96,10 @@ gimp_brushes_get_list (const gchar *filter,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_brushes = return_vals[1].data.d_int32;
brush_list = g_new (gchar *, *num_brushes);
brush_list = g_new (gchar *, *num_brushes + 1);
for (i = 0; i < *num_brushes; i++)
brush_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
brush_list[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -67,9 +67,10 @@ gimp_buffers_get_list (const gchar *filter,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_buffers = return_vals[1].data.d_int32;
buffer_list = g_new (gchar *, *num_buffers);
buffer_list = g_new (gchar *, *num_buffers + 1);
for (i = 0; i < *num_buffers; i++)
buffer_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
buffer_list[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -165,9 +165,10 @@ gimp_context_list_paint_methods (gint *num_paint_methods,
if (success)
{
*num_paint_methods = return_vals[1].data.d_int32;
*paint_methods = g_new (gchar *, *num_paint_methods);
*paint_methods = g_new (gchar *, *num_paint_methods + 1);
for (i = 0; i < *num_paint_methods; i++)
(*paint_methods)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
(*paint_methods)[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -98,9 +98,10 @@ gimp_dynamics_get_list (const gchar *filter,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_dynamics = return_vals[1].data.d_int32;
dynamics_list = g_new (gchar *, *num_dynamics);
dynamics_list = g_new (gchar *, *num_dynamics + 1);
for (i = 0; i < *num_dynamics; i++)
dynamics_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
dynamics_list[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -93,9 +93,10 @@ gimp_fonts_get_list (const gchar *filter,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_fonts = return_vals[1].data.d_int32;
font_list = g_new (gchar *, *num_fonts);
font_list = g_new (gchar *, *num_fonts + 1);
for (i = 0; i < *num_fonts; i++)
font_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
font_list[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -96,9 +96,10 @@ gimp_gradients_get_list (const gchar *filter,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_gradients = return_vals[1].data.d_int32;
gradient_list = g_new (gchar *, *num_gradients);
gradient_list = g_new (gchar *, *num_gradients + 1);
for (i = 0; i < *num_gradients; i++)
gradient_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
gradient_list[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -3109,9 +3109,10 @@ gimp_image_get_parasite_list (gint32 image_ID,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_parasites = return_vals[1].data.d_int32;
parasites = g_new (gchar *, *num_parasites);
parasites = g_new (gchar *, *num_parasites + 1);
for (i = 0; i < *num_parasites; i++)
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
parasites[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -1005,9 +1005,10 @@ gimp_item_get_parasite_list (gint32 item_ID,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_parasites = return_vals[1].data.d_int32;
parasites = g_new (gchar *, *num_parasites);
parasites = g_new (gchar *, *num_parasites + 1);
for (i = 0; i < *num_parasites; i++)
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
parasites[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -94,9 +94,10 @@ gimp_palettes_get_list (const gchar *filter,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_palettes = return_vals[1].data.d_int32;
palette_list = g_new (gchar *, *num_palettes);
palette_list = g_new (gchar *, *num_palettes + 1);
for (i = 0; i < *num_palettes; i++)
palette_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
palette_list[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -64,9 +64,10 @@ gimp_path_list (gint32 image_ID,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_paths = return_vals[1].data.d_int32;
path_list = g_new (gchar *, *num_paths);
path_list = g_new (gchar *, *num_paths + 1);
for (i = 0; i < *num_paths; i++)
path_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
path_list[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -96,9 +96,10 @@ gimp_patterns_get_list (const gchar *filter,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_patterns = return_vals[1].data.d_int32;
pattern_list = g_new (gchar *, *num_patterns);
pattern_list = g_new (gchar *, *num_patterns + 1);
for (i = 0; i < *num_patterns; i++)
pattern_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
pattern_list[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -162,9 +162,10 @@ gimp_procedural_db_query (const gchar *name,
if (success)
{
*num_matches = return_vals[1].data.d_int32;
*procedure_names = g_new (gchar *, *num_matches);
*procedure_names = g_new (gchar *, *num_matches + 1);
for (i = 0; i < *num_matches; i++)
(*procedure_names)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
(*procedure_names)[i] = NULL;
}
gimp_destroy_params (return_vals, nreturn_vals);
......
......@@ -265,7 +265,10 @@ CODE
my $arg = $arg_types{$type};
my $var;
my $ch = ""; my $cf = "";
my $ch = ""; my $cf = ""; my $numvarplus = "";
if ($type =~ /stringarray/) {
$numvarplus = ' + 1';
}
if ($type =~ /^string(array)?/) {
$ch = 'g_strdup (';
$cf = ')';
......@@ -312,7 +315,7 @@ CODE
$return_marshal .= <<NEW . (($ch || $cf) ? <<CP1 : <<CP2);
$numvar = return_vals[$numpos].data.d_$numtype;
$var = g_new ($datatype, $numvar);
$var = g_new ($datatype, $numvar$numvarplus);
NEW
for (i = 0; i < $numvar; i++)
$dh$_->{name}$df\[i] = ${ch}return_vals[$argc].data.d_$type\[i]${cf};
......@@ -321,6 +324,11 @@ CP1
return_vals[$argc].data.d_$type,
$numvar * sizeof ($datatype));
CP2
if ($type =~ /stringarray/) {
$return_marshal .= <<FINISH
$dh$_->{name}$df\[i] = NULL;
FINISH
}
$out->{headers} = "#include <string.h>\n" unless ($ch || $cf);
}
else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment