summaryrefslogtreecommitdiff
path: root/gsk/gsktransform.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2019-03-22 11:45:57 +0000
committerBenjamin Otte <otte@redhat.com>2019-04-29 02:25:18 +0200
commit478fdaa63237d726850dd94c5bb4f486f3027952 (patch)
tree94a39e268cbe678a9c163d045ec483c1ad0d205b /gsk/gsktransform.c
parent7420f9c34ac21016d0e1677a1bc7eebebda84ad7 (diff)
downloadgtk+-478fdaa63237d726850dd94c5bb4f486f3027952.tar.gz
Use atomic boxing instead of manual refcounting
Artisanal, homegrown, locally sourced, vegan reference counting has been replaced by the appropriate API in GLib, which does small things like saturation and type checking.
Diffstat (limited to 'gsk/gsktransform.c')
-rw-r--r--gsk/gsktransform.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c
index 1dfd9b9740..428132bdfb 100644
--- a/gsk/gsktransform.c
+++ b/gsk/gsktransform.c
@@ -42,8 +42,7 @@ typedef struct _GskTransformClass GskTransformClass;
struct _GskTransform
{
const GskTransformClass *transform_class;
-
- volatile int ref_count;
+
GskTransformCategory category;
GskTransform *next;
};
@@ -113,10 +112,9 @@ gsk_transform_alloc (const GskTransformClass *transform_class,
g_return_val_if_fail (transform_class != NULL, NULL);
- self = g_malloc0 (transform_class->struct_size);
+ self = g_atomic_rc_box_alloc0 (transform_class->struct_size);
self->transform_class = transform_class;
- self->ref_count = 1;
self->category = next ? MIN (category, next->category) : category;
self->next = gsk_transform_is_identity (next) ? NULL : next;
@@ -1217,8 +1215,6 @@ gsk_transform_finalize (GskTransform *self)
self->transform_class->finalize (self);
gsk_transform_unref (self->next);
-
- g_free (self);
}
/**
@@ -1235,9 +1231,7 @@ gsk_transform_ref (GskTransform *self)
if (self == NULL)
return NULL;
- g_atomic_int_inc (&self->ref_count);
-
- return self;
+ return g_atomic_rc_box_acquire (self);
}
/**
@@ -1255,8 +1249,7 @@ gsk_transform_unref (GskTransform *self)
if (self == NULL)
return;
- if (g_atomic_int_dec_and_test (&self->ref_count))
- gsk_transform_finalize (self);
+ g_atomic_rc_box_release_full (self, (GDestroyNotify) gsk_transform_finalize);
}
/**