[devhelp] DhLink: do not use atomic operations for ref/unref



commit 9a37d8653b1a1f7c37b6a99f3e6d2235a24becea
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Dec 7 15:28:01 2017 +0100

    DhLink: do not use atomic operations for ref/unref
    
    Not needed for the Devhelp codebase.

 src/dh-link.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/dh-link.c b/src/dh-link.c
index a252789..223d86a 100644
--- a/src/dh-link.c
+++ b/src/dh-link.c
@@ -161,6 +161,8 @@ dh_link_new (DhLinkType   type,
  *
  * Increases the reference count of @link.
  *
+ * Not thread-safe.
+ *
  * Returns: (transfer full): the @link.
  */
 DhLink *
@@ -168,7 +170,7 @@ dh_link_ref (DhLink *link)
 {
         g_return_val_if_fail (link != NULL, NULL);
 
-        g_atomic_int_inc (&link->ref_count);
+        link->ref_count++;
 
         return link;
 }
@@ -178,16 +180,18 @@ dh_link_ref (DhLink *link)
  * @link: a #DhLink.
  *
  * Decreases the reference count of @link.
+ *
+ * Not thread-safe.
  */
 void
 dh_link_unref (DhLink *link)
 {
         g_return_if_fail (link != NULL);
 
-        if (g_atomic_int_dec_and_test (&link->ref_count))
-        {
+        if (link->ref_count == 1)
                 link_free (link);
-        }
+        else
+                link->ref_count--;
 }
 
 /**


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