diff options
author | Timm Bäder <mail@baedert.org> | 2018-01-02 08:36:10 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2018-01-02 08:36:10 +0100 |
commit | 355b883f32314fb6d3bff3d9dccbae264c542df5 (patch) | |
tree | fdf86de923ae4b78f4ce1b7a6b68a1d590e3bee8 | |
parent | fcc8d778b544379e2ceabd3dcade7c502172f64b (diff) | |
download | gtk+-355b883f32314fb6d3bff3d9dccbae264c542df5.tar.gz |
stack-allocate GtkCssLookup instances
-rw-r--r-- | gtk/gtkcsslookup.c | 16 | ||||
-rw-r--r-- | gtk/gtkcsslookupprivate.h | 5 | ||||
-rw-r--r-- | gtk/gtkcssstaticstyle.c | 10 |
3 files changed, 13 insertions, 18 deletions
diff --git a/gtk/gtkcsslookup.c b/gtk/gtkcsslookup.c index 3a4c02d003..cc1df1d2f9 100644 --- a/gtk/gtkcsslookup.c +++ b/gtk/gtkcsslookup.c @@ -24,12 +24,11 @@ #include "gtkprivatetypebuiltins.h" #include "gtkprivate.h" -GtkCssLookup * -_gtk_css_lookup_new (const GtkBitmask *relevant) +void +_gtk_css_lookup_init (GtkCssLookup *lookup, + const GtkBitmask *relevant) { - GtkCssLookup *lookup; - - lookup = g_malloc0 (sizeof (GtkCssLookup)); + memset (lookup, 0, sizeof (*lookup)); if (relevant) { @@ -40,17 +39,12 @@ _gtk_css_lookup_new (const GtkBitmask *relevant) lookup->missing = _gtk_bitmask_new (); lookup->missing = _gtk_bitmask_invert_range (lookup->missing, 0, GTK_CSS_PROPERTY_N_PROPERTIES); } - - return lookup; } void -_gtk_css_lookup_free (GtkCssLookup *lookup) +_gtk_css_lookup_destroy (GtkCssLookup *lookup) { - gtk_internal_return_if_fail (lookup != NULL); - _gtk_bitmask_free (lookup->missing); - g_free (lookup); } gboolean diff --git a/gtk/gtkcsslookupprivate.h b/gtk/gtkcsslookupprivate.h index 8aaa913c32..ca4094d940 100644 --- a/gtk/gtkcsslookupprivate.h +++ b/gtk/gtkcsslookupprivate.h @@ -38,8 +38,9 @@ struct _GtkCssLookup { GtkCssLookupValue values[GTK_CSS_PROPERTY_N_PROPERTIES]; }; -GtkCssLookup * _gtk_css_lookup_new (const GtkBitmask *relevant); -void _gtk_css_lookup_free (GtkCssLookup *lookup); +void _gtk_css_lookup_init (GtkCssLookup *lookup, + const GtkBitmask *relevant); +void _gtk_css_lookup_destroy (GtkCssLookup *lookup); static inline const GtkBitmask *_gtk_css_lookup_get_missing (const GtkCssLookup *lookup); gboolean _gtk_css_lookup_is_missing (const GtkCssLookup *lookup, diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c index 1152399d29..a87b409761 100644 --- a/gtk/gtkcssstaticstyle.c +++ b/gtk/gtkcssstaticstyle.c @@ -172,27 +172,27 @@ gtk_css_static_style_new_compute (GtkStyleProvider *provider, GtkCssStyle *parent) { GtkCssStaticStyle *result; - GtkCssLookup *lookup; + GtkCssLookup lookup; GtkCssChange change = GTK_CSS_CHANGE_ANY_SELF | GTK_CSS_CHANGE_ANY_SIBLING | GTK_CSS_CHANGE_ANY_PARENT; - lookup = _gtk_css_lookup_new (NULL); + _gtk_css_lookup_init (&lookup, NULL); if (matcher) gtk_style_provider_lookup (provider, matcher, - lookup, + &lookup, &change); result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL); result->change = change; - _gtk_css_lookup_resolve (lookup, + _gtk_css_lookup_resolve (&lookup, provider, result, parent); - _gtk_css_lookup_free (lookup); + _gtk_css_lookup_destroy (&lookup); return GTK_CSS_STYLE (result); } |