pango r2705 - in trunk: . pango
- From: behdad svn gnome org
- To: svn-commits-list gnome org
- Subject: pango r2705 - in trunk: . pango
- Date: Fri, 22 Aug 2008 07:20:04 +0000 (UTC)
Author: behdad
Date: Fri Aug 22 07:20:04 2008
New Revision: 2705
URL: http://svn.gnome.org/viewvc/pango?rev=2705&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/pango/fonts.c
trunk/pango/pango-attributes.c
trunk/pango/pango-coverage.c
trunk/pango/pango-layout.c
trunk/pango/pangowin32-fontcache.c
trunk/pango/pangox-fontcache.c
Modified: trunk/pango/fonts.c
==============================================================================
--- trunk/pango/fonts.c (original)
+++ trunk/pango/fonts.c Fri Aug 22 07:20:04 2008
@@ -1489,7 +1489,7 @@
if (metrics == NULL)
return NULL;
- metrics->ref_count++;
+ g_atomic_int_inc (&metrics->ref_count);
return metrics;
}
@@ -1510,9 +1510,7 @@
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);
}
Modified: trunk/pango/pango-attributes.c
==============================================================================
--- trunk/pango/pango-attributes.c (original)
+++ trunk/pango/pango-attributes.c Fri Aug 22 07:20:04 2008
@@ -1131,7 +1131,7 @@
if (list == NULL)
return NULL;
- list->ref_count++;
+ g_atomic_int_inc (&list->ref_count);
return list;
}
@@ -1154,8 +1154,7 @@
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)
Modified: trunk/pango/pango-coverage.c
==============================================================================
--- trunk/pango/pango-coverage.c (original)
+++ trunk/pango/pango-coverage.c Fri Aug 22 07:20:04 2008
@@ -122,7 +122,7 @@
{
g_return_val_if_fail (coverage != NULL, NULL);
- coverage->ref_count++;
+ g_atomic_int_inc (&coverage->ref_count);
return coverage;
}
@@ -142,9 +142,7 @@
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);
Modified: trunk/pango/pango-layout.c
==============================================================================
--- trunk/pango/pango-layout.c (original)
+++ trunk/pango/pango-layout.c Fri Aug 22 07:20:04 2008
@@ -3878,7 +3878,7 @@
if (line == NULL)
return NULL;
- private->ref_count++;
+ g_atomic_int_inc (&private->ref_count);
return line;
}
@@ -3901,8 +3901,7 @@
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);
Modified: trunk/pango/pangowin32-fontcache.c
==============================================================================
--- trunk/pango/pangowin32-fontcache.c (original)
+++ trunk/pango/pangowin32-fontcache.c Fri Aug 22 07:20:04 2008
@@ -160,8 +160,7 @@
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 @@
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 @@
}
else
{
- entry->ref_count++;
+ g_atomic_int_inc (entry->ref_count);
/* Insert into the mru list */
Modified: trunk/pango/pangox-fontcache.c
==============================================================================
--- trunk/pango/pangox-fontcache.c (original)
+++ trunk/pango/pangox-fontcache.c Fri Aug 22 07:20:04 2008
@@ -118,8 +118,7 @@
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 @@
if (entry)
{
- entry->ref_count++;
+ g_atomic_int_inc (&entry->ref_count);
}
else
{
@@ -200,7 +199,7 @@
}
else
{
- entry->ref_count++;
+ g_atomic_int_inc (&entry->ref_count);
/* Insert into the mru list */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]