summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--pango/fonts.c6
-rw-r--r--pango/pango-attributes.c5
-rw-r--r--pango/pango-coverage.c6
-rw-r--r--pango/pango-layout.c5
-rw-r--r--pango/pangowin32-fontcache.c7
-rw-r--r--pango/pangox-fontcache.c7
7 files changed, 33 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f9b5d38..888477cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
2008-08-22 Behdad Esfahbod <behdad@gnome.org>
+ * pango/fonts.c (pango_font_metrics_ref),
+ (pango_font_metrics_unref):
+ * pango/pango-attributes.c (pango_attr_list_ref),
+ (pango_attr_list_unref):
+ * pango/pango-coverage.c (pango_coverage_ref),
+ (pango_coverage_unref):
+ * pango/pango-layout.c (pango_layout_line_ref),
+ (pango_layout_line_unref):
+ * pango/pangowin32-fontcache.c (cache_entry_unref),
+ (pango_win32_font_cache_loadw):
+ * pango/pangox-fontcache.c (cache_entry_unref),
+ (pango_x_font_cache_load):
+ Use atomic reference counting.
+
+ Pango may not be thread safe yet, but fixing it little by little
+ is easier than doing all in one round.
+
+2008-08-22 Behdad Esfahbod <behdad@gnome.org>
+
Bug 143542 – PangoFT2Fontmap leak
* pango/fonts.c:
diff --git a/pango/fonts.c b/pango/fonts.c
index 2f997035..066c54ce 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1489,7 +1489,7 @@ pango_font_metrics_ref (PangoFontMetrics *metrics)
if (metrics == NULL)
return NULL;
- metrics->ref_count++;
+ g_atomic_int_inc (&metrics->ref_count);
return metrics;
}
@@ -1510,9 +1510,7 @@ pango_font_metrics_unref (PangoFontMetrics *metrics)
g_return_if_fail (metrics->ref_count > 0 );
- metrics->ref_count--;
-
- if (metrics->ref_count == 0)
+ if (g_atomic_int_dec_and_test (&metrics->ref_count))
g_slice_free (PangoFontMetrics, metrics);
}
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 3a0be40b..5e5e5857 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1131,7 +1131,7 @@ pango_attr_list_ref (PangoAttrList *list)
if (list == NULL)
return NULL;
- list->ref_count++;
+ g_atomic_int_inc (&list->ref_count);
return list;
}
@@ -1154,8 +1154,7 @@ pango_attr_list_unref (PangoAttrList *list)
g_return_if_fail (list->ref_count > 0);
- list->ref_count--;
- if (list->ref_count == 0)
+ if (g_atomic_int_dec_and_test (&list->ref_count))
{
tmp_list = list->attributes;
while (tmp_list)
diff --git a/pango/pango-coverage.c b/pango/pango-coverage.c
index f22431b7..77559d0a 100644
--- a/pango/pango-coverage.c
+++ b/pango/pango-coverage.c
@@ -122,7 +122,7 @@ pango_coverage_ref (PangoCoverage *coverage)
{
g_return_val_if_fail (coverage != NULL, NULL);
- coverage->ref_count++;
+ g_atomic_int_inc (&coverage->ref_count);
return coverage;
}
@@ -142,9 +142,7 @@ pango_coverage_unref (PangoCoverage *coverage)
g_return_if_fail (coverage != NULL);
g_return_if_fail (coverage->ref_count > 0);
- coverage->ref_count--;
-
- if (coverage->ref_count == 0)
+ if (g_atomic_int_dec_and_test (&coverage->ref_count))
{
for (i=0; i<coverage->n_blocks; i++)
g_free (coverage->blocks[i].data);
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 262b4035..f4c307db 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3878,7 +3878,7 @@ pango_layout_line_ref (PangoLayoutLine *line)
if (line == NULL)
return NULL;
- private->ref_count++;
+ g_atomic_int_inc (&private->ref_count);
return line;
}
@@ -3901,8 +3901,7 @@ pango_layout_line_unref (PangoLayoutLine *line)
g_return_if_fail (private->ref_count > 0);
- private->ref_count--;
- if (private->ref_count == 0)
+ if (g_atomic_int_dec_and_test (&private->ref_count))
{
g_slist_foreach (line->runs, (GFunc)free_run, GINT_TO_POINTER (1));
g_slist_free (line->runs);
diff --git a/pango/pangowin32-fontcache.c b/pango/pangowin32-fontcache.c
index b6934d49..577e3b85 100644
--- a/pango/pangowin32-fontcache.c
+++ b/pango/pangowin32-fontcache.c
@@ -160,8 +160,7 @@ static void
cache_entry_unref (PangoWin32FontCache *cache,
CacheEntry *entry)
{
- entry->ref_count--;
- if (entry->ref_count == 0)
+ if (g_atomic_int_dec_and_test (&entry->ref_count))
{
PING (("removing cache entry %p", entry->hfont));
@@ -233,7 +232,7 @@ pango_win32_font_cache_loadw (PangoWin32FontCache *cache,
if (entry)
{
- entry->ref_count++;
+ g_atomic_int_inc (entry->ref_count);
PING (("increased refcount for cache entry %p: %d", entry->hfont, entry->ref_count));
}
else
@@ -384,7 +383,7 @@ pango_win32_font_cache_loadw (PangoWin32FontCache *cache,
}
else
{
- entry->ref_count++;
+ g_atomic_int_inc (entry->ref_count);
/* Insert into the mru list */
diff --git a/pango/pangox-fontcache.c b/pango/pangox-fontcache.c
index a56fe737..c1177b8b 100644
--- a/pango/pangox-fontcache.c
+++ b/pango/pangox-fontcache.c
@@ -118,8 +118,7 @@ pango_x_font_cache_new (Display *display)
static void
cache_entry_unref (PangoXFontCache *cache, CacheEntry *entry)
{
- entry->ref_count--;
- if (entry->ref_count == 0)
+ if (g_atomic_int_dec_and_test (&entry->ref_count))
{
g_hash_table_remove (cache->forward, entry->xlfd);
g_hash_table_remove (cache->back, entry->fs);
@@ -154,7 +153,7 @@ pango_x_font_cache_load (PangoXFontCache *cache,
if (entry)
{
- entry->ref_count++;
+ g_atomic_int_inc (&entry->ref_count);
}
else
{
@@ -200,7 +199,7 @@ pango_x_font_cache_load (PangoXFontCache *cache,
}
else
{
- entry->ref_count++;
+ g_atomic_int_inc (&entry->ref_count);
/* Insert into the mru list */