[libgweather/wip/tintou/modern-code: 5/5] timezone: use the G_DEFINE_BOXED_TYPE macro
- From: Corentin Noël <corentinnoel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/wip/tintou/modern-code: 5/5] timezone: use the G_DEFINE_BOXED_TYPE macro
- Date: Wed, 7 Oct 2020 14:36:53 +0000 (UTC)
commit 386bcbe7a2af98f2e9c975c22fa086006939ad42
Author: Corentin Noël <corentin noel collabora com>
Date: Wed Oct 7 16:34:28 2020 +0200
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 3916dc57..e44ada84 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 260a2fca..7c7cb382 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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]