diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-02-04 12:19:23 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-02-04 12:19:23 +0100 |
commit | b8ffe5b2452f829c45271c64743af89d38f78230 (patch) | |
tree | 7a4f1de853243b4f11ca2f321cb148c6d4bf0a52 /gtk/gtkcssstyle.c | |
parent | 4685fe1716b812c6f5803a15d40cd7da7cfe694d (diff) | |
download | gtk+-b8ffe5b2452f829c45271c64743af89d38f78230.tar.gz |
css: Fix the initial values optimization
Fix up the index computation. We have duplicate entries
in the type enum, so to go from one of the 'initial' types
to it corresponding type you subtract one, but to find
the size array entry for a type, you divide by 2.
Diffstat (limited to 'gtk/gtkcssstyle.c')
-rw-r--r-- | gtk/gtkcssstyle.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c index 5707b0eb55..ecfc3f45cd 100644 --- a/gtk/gtkcssstyle.c +++ b/gtk/gtkcssstyle.c @@ -690,30 +690,21 @@ gtk_css_style_get_pango_font (GtkCssStyle *style) static int values_size[] = { sizeof (GtkCssCoreValues), - sizeof (GtkCssCoreValues), - sizeof (GtkCssBackgroundValues), sizeof (GtkCssBackgroundValues), sizeof (GtkCssBorderValues), - sizeof (GtkCssBorderValues), sizeof (GtkCssIconValues), - sizeof (GtkCssIconValues), - sizeof (GtkCssOutlineValues), sizeof (GtkCssOutlineValues), sizeof (GtkCssFontValues), - sizeof (GtkCssFontValues), - sizeof (GtkCssFontVariantValues), sizeof (GtkCssFontVariantValues), sizeof (GtkCssAnimationValues), - sizeof (GtkCssAnimationValues), sizeof (GtkCssTransitionValues), - sizeof (GtkCssTransitionValues), - sizeof (GtkCssSizeValues), sizeof (GtkCssSizeValues), - sizeof (GtkCssOtherValues), sizeof (GtkCssOtherValues) }; -#define N_VALUES(type) ((values_size[type] - sizeof (GtkCssValues)) / sizeof (GtkCssValue *)) +#define TYPE_INDEX(type) ((type) - ((type) % 2)) +#define VALUES_SIZE(type) (values_size[(type) / 2]) +#define N_VALUES(type) ((VALUES_SIZE(type) - sizeof (GtkCssValues)) / sizeof (GtkCssValue *)) #define GET_VALUES(v) (GtkCssValue **)((guint8 *)(v) + sizeof (GtkCssValues)) @@ -757,7 +748,7 @@ gtk_css_values_copy (GtkCssValues *values) GtkCssValue **v, **v2; int i; - copy = gtk_css_values_new (values->type - (values->type % 2)); + copy = gtk_css_values_new (TYPE_INDEX(values->type)); v = GET_VALUES (values); v2 = GET_VALUES (copy); @@ -776,9 +767,9 @@ gtk_css_values_new (GtkCssValuesType type) { GtkCssValues *values; - values = (GtkCssValues *)g_malloc0 (values_size[type]); + values = (GtkCssValues *)g_malloc0 (VALUES_SIZE(type)); values->ref_count = 1; - values->type = type - (type % 2); + values->type = type; return values; } |