[librsvg: 9/95] Don't pass an allocated closure to g_hash_table_foreach()



commit 1ff98de56bc38664f17adf1b8bdcbf86e7c7b292
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Feb 8 10:51:58 2018 -0600

    Don't pass an allocated closure to g_hash_table_foreach()
    
    The closure is short-lived; there's no need to keep it on the heap.

 rsvg-styles.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
---
diff --git a/rsvg-styles.c b/rsvg-styles.c
index d08c0ce0..ee1b5fac 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -1501,16 +1501,11 @@ rsvg_parse_transform_attr (RsvgState *state, const char *str)
     }
 }
 
-typedef struct _StylesData {
-    RsvgHandle *handle;
-    RsvgState *state;
-} StylesData;
-
 static void
 apply_style (const gchar *key, StyleValueData *value, gpointer user_data)
 {
-    StylesData *data = (StylesData *) user_data;
-    rsvg_parse_style_pair (data->state, key, value->value, value->important);
+    RsvgState *state = user_data;
+    rsvg_parse_style_pair (state, key, value->value, value->important);
 }
 
 static gboolean
@@ -1521,11 +1516,7 @@ rsvg_lookup_apply_css_style (RsvgHandle *handle, const char *target, RsvgState *
     styles = g_hash_table_lookup (handle->priv->css_props, target);
 
     if (styles != NULL) {
-        StylesData *data = g_new0 (StylesData, 1);
-        data->handle = handle;
-        data->state = state;
-        g_hash_table_foreach (styles, (GHFunc) apply_style, data);
-        g_free (data);
+        g_hash_table_foreach (styles, (GHFunc) apply_style, state);
         return TRUE;
     }
     return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]