[pango: 1/4] Extract function to free the contents of a PangoFcPatterns




commit f651add3298878fe97b4da63e481b20f72c982aa
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Jul 1 16:55:52 2021 -0500

    Extract function to free the contents of a PangoFcPatterns

 pango/pangofc-fontmap.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 0df9de9f..ade1b38a 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -917,14 +917,9 @@ pango_fc_patterns_ref (PangoFcPatterns *pats)
 }
 
 static void
-pango_fc_patterns_unref (PangoFcPatterns *pats)
+free_patterns (gpointer data)
 {
-  g_return_if_fail (pats->ref_count > 0);
-
-  pats->ref_count--;
-
-  if (pats->ref_count)
-    return;
+  PangoFcPatterns *pats = data;
 
   /* Only remove from fontmap hash if we are in it.  This is not necessarily
    * the case after a cache_clear() call. */
@@ -944,7 +939,19 @@ pango_fc_patterns_unref (PangoFcPatterns *pats)
 
   g_cond_clear (&pats->cond);
   g_mutex_clear (&pats->mutex);
+}
+
+static void
+pango_fc_patterns_unref (PangoFcPatterns *pats)
+{
+  g_return_if_fail (pats->ref_count > 0);
+
+  pats->ref_count--;
+
+  if (pats->ref_count)
+    return;
 
+  free_patterns (pats);
   g_slice_free (PangoFcPatterns, pats);
 }
 


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