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 "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

View File

@ -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,

View File

@ -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);
}