From 7311ce178247e2da77c064e0e34f6e50f992f854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Wed, 7 Oct 2020 16:34:28 +0200 Subject: timezone: use the G_DEFINE_BOXED_TYPE macro This allows to remove a little bit of boilerplate code. --- libgweather/gweather-timezone.c | 17 ++--------------- libgweather/gweather-timezone.h | 2 ++ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/libgweather/gweather-timezone.c b/libgweather/gweather-timezone.c index 3916dc5..e44ada8 100644 --- a/libgweather/gweather-timezone.c +++ b/libgweather/gweather-timezone.c @@ -48,6 +48,8 @@ struct _GWeatherTimezone { int ref_count; }; +G_DEFINE_BOXED_TYPE (GWeatherTimezone, gweather_timezone, gweather_timezone_ref, gweather_timezone_unref); + #define TZ_MAGIC "TZif" #define TZ_HEADER_SIZE 44 #define TZ_TIMECNT_OFFSET 32 @@ -310,21 +312,6 @@ gweather_timezone_unref (GWeatherTimezone *zone) } } -GType -gweather_timezone_get_type (void) -{ - static volatile gsize type_volatile = 0; - - if (g_once_init_enter (&type_volatile)) { - GType type = g_boxed_type_register_static ( - g_intern_static_string ("GWeatherTimezone"), - (GBoxedCopyFunc) gweather_timezone_ref, - (GBoxedFreeFunc) gweather_timezone_unref); - g_once_init_leave (&type_volatile, type); - } - return type_volatile; -} - /** * gweather_timezone_get_utc: * diff --git a/libgweather/gweather-timezone.h b/libgweather/gweather-timezone.h index 260a2fc..7c7cb38 100644 --- a/libgweather/gweather-timezone.h +++ b/libgweather/gweather-timezone.h @@ -56,6 +56,8 @@ GWeatherTimezone *gweather_timezone_get_utc (void); GWEATHER_EXTERN GWeatherTimezone *gweather_timezone_get_by_tzid (const char *tzid); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GWeatherTimezone, gweather_timezone_unref) + G_END_DECLS #endif /* __GWEATHER_TIMEZONE_H__ */ -- cgit v1.2.1