summaryrefslogtreecommitdiff
path: root/gtk/gtkcssshadowsvalue.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2017-09-30 13:11:51 +0200
committerTimm Bäder <mail@baedert.org>2017-10-01 09:19:09 +0200
commit773973db78eba52e32d273a67387fd360fcdbb20 (patch)
tree5da33a96b2f897aabdfefc9154c0c3e9c6b4ae6d /gtk/gtkcssshadowsvalue.c
parent53409623e548529d9e702e6858b7cd8bbe26b48b (diff)
downloadgtk+-773973db78eba52e32d273a67387fd360fcdbb20.tar.gz
cssshadowsvalue: Don't heap-allocate shadows
This showed up in profiles in certain scenarios, so export a _get_n_shadows getter instead and let callers provide a sufficiently large allocated array of GskShadows, which we can use with g_alloc/g_newa.
Diffstat (limited to 'gtk/gtkcssshadowsvalue.c')
-rw-r--r--gtk/gtkcssshadowsvalue.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c
index 40fb07af6c..bd687dc156 100644
--- a/gtk/gtkcssshadowsvalue.c
+++ b/gtk/gtkcssshadowsvalue.c
@@ -268,23 +268,20 @@ _gtk_css_shadows_value_is_none (const GtkCssValue *shadows)
return shadows->len == 0;
}
-GskShadow *
-gtk_css_shadows_value_get_shadows (const GtkCssValue *shadows,
- gsize *n_shadows)
+gsize
+gtk_css_shadows_value_get_n_shadows (const GtkCssValue *shadows)
{
- GskShadow *result;
- guint i;
+ return shadows->len;
+}
- result = g_new (GskShadow, shadows->len);
+void
+gtk_css_shadows_value_get_shadows (const GtkCssValue *shadows,
+ GskShadow *out_shadows)
+{
+ guint i;
for (i = 0; i < shadows->len; i++)
- {
- gtk_css_shadow_value_get_shadow (shadows->values[i], &result[i]);
- }
-
- *n_shadows = shadows->len;
-
- return result;
+ gtk_css_shadow_value_get_shadow (shadows->values[i], &out_shadows[i]);
}
void