summaryrefslogtreecommitdiff
path: root/gtk/gtkaccessibleattributeset.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-03-19 17:00:04 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-03-19 17:01:28 -0400
commit3cfe69d71108a47f080819edbc9e884199361d8f (patch)
treef1fcc0ff687d34b6b0685d7886bccefe1137cb75 /gtk/gtkaccessibleattributeset.c
parentb9da74590be6860c55fa2dca7b61d785ae174fe6 (diff)
downloadgtk+-3cfe69d71108a47f080819edbc9e884199361d8f.tar.gz
a11y: Don't copy attribute names in attribute setsa11y-strdup
We only need these names when serializing a11y information for tests. And copying these strings is entirely unnecessary. So, just pass a callback instead.
Diffstat (limited to 'gtk/gtkaccessibleattributeset.c')
-rw-r--r--gtk/gtkaccessibleattributeset.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/gtk/gtkaccessibleattributeset.c b/gtk/gtkaccessibleattributeset.c
index f49a9cf911..2e7a072abc 100644
--- a/gtk/gtkaccessibleattributeset.c
+++ b/gtk/gtkaccessibleattributeset.c
@@ -29,44 +29,41 @@ struct _GtkAccessibleAttributeSet
{
gsize n_attributes;
+ GtkAccessibleAttributeNameFunc name_func;
GtkAccessibleAttributeDefaultFunc default_func;
GtkBitmask *attributes_set;
- char **attribute_names;
GtkAccessibleValue **attribute_values;
};
static GtkAccessibleAttributeSet *
gtk_accessible_attribute_set_init (GtkAccessibleAttributeSet *self,
gsize n_attributes,
- const char **attribute_names,
+ GtkAccessibleAttributeNameFunc name_func,
GtkAccessibleAttributeDefaultFunc default_func)
{
self->n_attributes = n_attributes;
+ self->name_func = name_func;
self->default_func = default_func;
- self->attribute_names = g_new (char *, n_attributes);
self->attribute_values = g_new (GtkAccessibleValue *, n_attributes);
self->attributes_set = _gtk_bitmask_new ();
/* Initialize all attribute values, so we can always get the full attribute */
for (int i = 0; i < self->n_attributes; i++)
- {
- self->attribute_names[i] = g_strdup (attribute_names[i]);
- self->attribute_values[i] = (* self->default_func) (i);
- }
+ self->attribute_values[i] = (* self->default_func) (i);
return self;
}
GtkAccessibleAttributeSet *
gtk_accessible_attribute_set_new (gsize n_attributes,
- const char **attribute_names,
+ GtkAccessibleAttributeNameFunc name_func,
GtkAccessibleAttributeDefaultFunc default_func)
{
GtkAccessibleAttributeSet *set = g_rc_box_new0 (GtkAccessibleAttributeSet);
- return gtk_accessible_attribute_set_init (set, n_attributes, attribute_names, default_func);
+ return gtk_accessible_attribute_set_init (set, n_attributes, name_func, default_func);
}
GtkAccessibleAttributeSet *
@@ -84,13 +81,10 @@ gtk_accessible_attribute_set_free (gpointer data)
for (int i = 0; i < self->n_attributes; i++)
{
- g_free (self->attribute_names[i]);
-
if (self->attribute_values[i] != NULL)
gtk_accessible_value_unref (self->attribute_values[i]);
}
- g_free (self->attribute_names);
g_free (self->attribute_values);
_gtk_bitmask_free (self->attributes_set);
@@ -247,7 +241,7 @@ gtk_accessible_attribute_set_print (GtkAccessibleAttributeSet *self,
continue;
g_string_append (buffer, " ");
- g_string_append (buffer, self->attribute_names[i]);
+ g_string_append (buffer, self->name_func (i));
g_string_append (buffer, ": ");
gtk_accessible_value_print (self->attribute_values[i], buffer);