From 738b17063a16f8fd90dafdebbfc8b4da9ca86327 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 4 Sep 2019 19:21:45 +0200 Subject: [PATCH] libgimpbase: add an own struct for GimpStringArray instead of re-using the GimpArray struct, which was confusing particularly because of the meaning of the "length" member. --- libgimpbase/gimpparamspecs.c | 6 +++--- libgimpbase/gimpparamspecs.h | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libgimpbase/gimpparamspecs.c b/libgimpbase/gimpparamspecs.c index 64d7241447..f1daa6fee7 100644 --- a/libgimpbase/gimpparamspecs.c +++ b/libgimpbase/gimpparamspecs.c @@ -860,11 +860,11 @@ gimp_string_array_new (const gchar **data, for (i = 0; i < length; i++) tmp[i] = g_strdup (data[i]); - array->data = (guint8 *) tmp; + array->data = tmp; } else { - array->data = (guint8 *) data; + array->data = (gchar **) data; } array->length = length; @@ -898,7 +898,7 @@ gimp_string_array_free (GimpStringArray *array) { if (! array->static_data) { - gchar **tmp = (gchar **) array->data; + gchar **tmp = array->data; gint i; for (i = 0; i < array->length; i++) diff --git a/libgimpbase/gimpparamspecs.h b/libgimpbase/gimpparamspecs.h index 20985cdaf7..ae12246981 100644 --- a/libgimpbase/gimpparamspecs.h +++ b/libgimpbase/gimpparamspecs.h @@ -306,7 +306,14 @@ void gimp_value_take_float_array (GValue *value, * GIMP_TYPE_STRING_ARRAY */ -typedef struct _GimpArray GimpStringArray; +typedef struct _GimpStringArray GimpStringArray; + +struct _GimpStringArray +{ + gchar **data; + gsize length; + gboolean static_data; +}; GimpStringArray * gimp_string_array_new (const gchar **data, gsize length,