From ce07c0559d5b8ea6df3f11c3b878385833add019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 18 Apr 2020 18:17:46 +0200 Subject: [PATCH] shorthandproperty: Use alloca() when parsing properties --- gtk/gtkcssshorthandproperty.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gtk/gtkcssshorthandproperty.c b/gtk/gtkcssshorthandproperty.c index 42ce06abc7..8b7807788f 100644 --- a/gtk/gtkcssshorthandproperty.c +++ b/gtk/gtkcssshorthandproperty.c @@ -67,12 +67,13 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property, GtkCssParser *parser) { GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property); + const guint n_props = shorthand->subproperties->len; GtkCssValue **data; GtkCssValue *result; guint i; - data = g_newa (GtkCssValue *, shorthand->subproperties->len); - memset (data, 0, sizeof (GtkCssValue *) * shorthand->subproperties->len); + data = g_newa (GtkCssValue *, n_props); + memset (data, 0, sizeof (GtkCssValue *) * n_props); if (gtk_css_parser_try_ident (parser, "initial")) { @@ -101,7 +102,7 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property, } else if (!shorthand->parse (shorthand, data, parser)) { - for (i = 0; i < shorthand->subproperties->len; i++) + for (i = 0; i < n_props; i++) { if (data[i] != NULL) _gtk_css_value_unref (data[i]); @@ -112,13 +113,13 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property, /* All values that aren't set by the parse func are set to their * default values here. * XXX: Is the default always initial or can it be inherit? */ - for (i = 0; i < shorthand->subproperties->len; i++) + for (i = 0; i < n_props; i++) { if (data[i] == NULL) data[i] = _gtk_css_initial_value_new (); } - result = _gtk_css_array_value_new_from_array (data, shorthand->subproperties->len); + result = _gtk_css_array_value_new_from_array (data, n_props); return result; }