diff options
author | Corentin Noël <corentin.noel@collabora.com> | 2020-10-07 16:34:28 +0200 |
---|---|---|
committer | Corentin Noël <corentin.noel@collabora.com> | 2020-11-24 16:22:25 +0100 |
commit | 7311ce178247e2da77c064e0e34f6e50f992f854 (patch) | |
tree | c55379b74fe138965b325c33980eb3c119dc095d | |
parent | e6ed138d04376e32536d95581ab5f2c1cc44e347 (diff) | |
download | libgweather-wip/tintou/modern-code.tar.gz |
timezone: use the G_DEFINE_BOXED_TYPE macrowip/tintou/modern-code
This allows to remove a little bit of boilerplate code.
-rw-r--r-- | libgweather/gweather-timezone.c | 17 | ||||
-rw-r--r-- | 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__ */ |