summaryrefslogtreecommitdiff
path: root/pango/pango-attributes.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2020-04-15 09:00:32 +0200
committerTimm Bäder <mail@baedert.org>2020-06-08 19:15:35 +0200
commit99431a5ce902ec6410ca4e73d49df8127405a97a (patch)
treef30dfa3b508867040b75ebb55f461c158f442d76 /pango/pango-attributes.c
parent03774a47fda0231fae38f44e68e05deaf9ca95dc (diff)
downloadpango-99431a5ce902ec6410ca4e73d49df8127405a97a.tar.gz
Allocate internal PangoAttrListIterators on the stack
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r--pango/pango-attributes.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 03a45de4..98e26872 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -34,6 +34,7 @@
#include <string.h>
#include "pango-attributes.h"
+#include "pango-attributes-private.h"
#include "pango-impl-utils.h"
struct _PangoAttrList
@@ -43,14 +44,6 @@ struct _PangoAttrList
GSList *attributes_tail;
};
-struct _PangoAttrIterator
-{
- GSList *next_attribute;
- GList *attribute_stack;
- guint start_index;
- guint end_index;
-};
-
static PangoAttribute *pango_attr_color_new (const PangoAttrClass *klass,
guint16 red,
guint16 green,
@@ -1997,6 +1990,20 @@ G_DEFINE_BOXED_TYPE (PangoAttrIterator,
pango_attr_iterator_copy,
pango_attr_iterator_destroy)
+void
+_pango_attr_list_get_iterator (PangoAttrList *list,
+ PangoAttrIterator *iterator)
+{
+ iterator->next_attribute = list->attributes;
+ iterator->attribute_stack = NULL;
+
+ iterator->start_index = 0;
+ iterator->end_index = 0;
+
+ if (!pango_attr_iterator_next (iterator))
+ iterator->end_index = G_MAXUINT;
+}
+
/**
* pango_attr_list_get_iterator:
* @list: a #PangoAttrList
@@ -2015,14 +2022,7 @@ pango_attr_list_get_iterator (PangoAttrList *list)
g_return_val_if_fail (list != NULL, NULL);
iterator = g_slice_new (PangoAttrIterator);
- iterator->next_attribute = list->attributes;
- iterator->attribute_stack = NULL;
-
- iterator->start_index = 0;
- iterator->end_index = 0;
-
- if (!pango_attr_iterator_next (iterator))
- iterator->end_index = G_MAXUINT;
+ _pango_attr_list_get_iterator (list, iterator);
return iterator;
}
@@ -2135,6 +2135,12 @@ pango_attr_iterator_copy (PangoAttrIterator *iterator)
return copy;
}
+void
+_pango_attr_iterator_destroy (PangoAttrIterator *iterator)
+{
+ g_list_free (iterator->attribute_stack);
+}
+
/**
* pango_attr_iterator_destroy:
* @iterator: a #PangoAttrIterator.
@@ -2146,7 +2152,7 @@ pango_attr_iterator_destroy (PangoAttrIterator *iterator)
{
g_return_if_fail (iterator != NULL);
- g_list_free (iterator->attribute_stack);
+ _pango_attr_iterator_destroy (iterator);
g_slice_free (PangoAttrIterator, iterator);
}