stack-allocate GtkCssLookup instances

This commit is contained in:
Timm Bäder 2018-01-02 08:36:10 +01:00
parent fcc8d778b5
commit 355b883f32
3 changed files with 13 additions and 18 deletions

View File

@ -24,12 +24,11 @@
#include "gtkprivatetypebuiltins.h" #include "gtkprivatetypebuiltins.h"
#include "gtkprivate.h" #include "gtkprivate.h"
GtkCssLookup * void
_gtk_css_lookup_new (const GtkBitmask *relevant) _gtk_css_lookup_init (GtkCssLookup *lookup,
const GtkBitmask *relevant)
{ {
GtkCssLookup *lookup; memset (lookup, 0, sizeof (*lookup));
lookup = g_malloc0 (sizeof (GtkCssLookup));
if (relevant) if (relevant)
{ {
@ -40,17 +39,12 @@ _gtk_css_lookup_new (const GtkBitmask *relevant)
lookup->missing = _gtk_bitmask_new (); lookup->missing = _gtk_bitmask_new ();
lookup->missing = _gtk_bitmask_invert_range (lookup->missing, 0, GTK_CSS_PROPERTY_N_PROPERTIES); lookup->missing = _gtk_bitmask_invert_range (lookup->missing, 0, GTK_CSS_PROPERTY_N_PROPERTIES);
} }
return lookup;
} }
void 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); _gtk_bitmask_free (lookup->missing);
g_free (lookup);
} }
gboolean gboolean

View File

@ -38,8 +38,9 @@ struct _GtkCssLookup {
GtkCssLookupValue values[GTK_CSS_PROPERTY_N_PROPERTIES]; GtkCssLookupValue values[GTK_CSS_PROPERTY_N_PROPERTIES];
}; };
GtkCssLookup * _gtk_css_lookup_new (const GtkBitmask *relevant); void _gtk_css_lookup_init (GtkCssLookup *lookup,
void _gtk_css_lookup_free (GtkCssLookup *lookup); const GtkBitmask *relevant);
void _gtk_css_lookup_destroy (GtkCssLookup *lookup);
static inline const GtkBitmask *_gtk_css_lookup_get_missing (const GtkCssLookup *lookup); static inline const GtkBitmask *_gtk_css_lookup_get_missing (const GtkCssLookup *lookup);
gboolean _gtk_css_lookup_is_missing (const GtkCssLookup *lookup, gboolean _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,

View File

@ -172,27 +172,27 @@ gtk_css_static_style_new_compute (GtkStyleProvider *provider,
GtkCssStyle *parent) GtkCssStyle *parent)
{ {
GtkCssStaticStyle *result; GtkCssStaticStyle *result;
GtkCssLookup *lookup; GtkCssLookup lookup;
GtkCssChange change = GTK_CSS_CHANGE_ANY_SELF | GTK_CSS_CHANGE_ANY_SIBLING | GTK_CSS_CHANGE_ANY_PARENT; 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) if (matcher)
gtk_style_provider_lookup (provider, gtk_style_provider_lookup (provider,
matcher, matcher,
lookup, &lookup,
&change); &change);
result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL); result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL);
result->change = change; result->change = change;
_gtk_css_lookup_resolve (lookup, _gtk_css_lookup_resolve (&lookup,
provider, provider,
result, result,
parent); parent);
_gtk_css_lookup_free (lookup); _gtk_css_lookup_destroy (&lookup);
return GTK_CSS_STYLE (result); return GTK_CSS_STYLE (result);
} }