[glib/wip/ebassi/rc: 4/4] Port GDateTime to g_ref_counter_*
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/ebassi/rc: 4/4] Port GDateTime to g_ref_counter_*
- Date: Tue, 15 Nov 2016 11:51:21 +0000 (UTC)
commit 7bf84d880f68ae9dacaf7714afbcdd611bf66d2b
Author: Emmanuele Bassi <ebassi gnome org>
Date: Tue Nov 15 11:49:07 2016 +0000
Port GDateTime to g_ref_counter_*
glib/gdatetime.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index 8ff0223..99d0540 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -64,6 +64,7 @@
#include "ghash.h"
#include "gmain.h"
#include "gmappedfile.h"
+#include "grefcount.h"
#include "gstrfuncs.h"
#include "gtestutils.h"
#include "gthread.h"
@@ -427,7 +428,8 @@ g_date_time_alloc (GTimeZone *tz)
datetime = g_slice_new0 (GDateTime);
datetime->tz = g_time_zone_ref (tz);
- datetime->ref_count = 1;
+
+ g_ref_counter_init (&datetime->ref_count, TRUE);
return datetime;
}
@@ -446,9 +448,8 @@ GDateTime *
g_date_time_ref (GDateTime *datetime)
{
g_return_val_if_fail (datetime != NULL, NULL);
- g_return_val_if_fail (datetime->ref_count > 0, NULL);
- g_atomic_int_inc (&datetime->ref_count);
+ g_ref_counter_acquire (&datetime->ref_count);
return datetime;
}
@@ -468,9 +469,8 @@ void
g_date_time_unref (GDateTime *datetime)
{
g_return_if_fail (datetime != NULL);
- g_return_if_fail (datetime->ref_count > 0);
- if (g_atomic_int_dec_and_test (&datetime->ref_count))
+ if (g_ref_counter_release (&datetime->ref_count))
{
g_time_zone_unref (datetime->tz);
g_slice_free (GDateTime, datetime);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]