diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-01-11 14:44:32 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-01-12 10:45:06 +0100 |
commit | 506425fc37b4c61874a3bb6dd69b8064552bf78d (patch) | |
tree | 799ca4c16ee125cdc9cb4c75f3f8d334c9234eb1 | |
parent | da3b4de921fcb1ef17d2b5b226ad9e4772f41e5e (diff) | |
download | libgweather-506425fc37b4c61874a3bb6dd69b8064552bf78d.tar.gz |
gweather: Use g_clear_* macros when possible
-rw-r--r-- | libgweather/gweather-weather.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c index 87aab72..7070199 100644 --- a/libgweather/gweather-weather.c +++ b/libgweather/gweather-weather.c @@ -530,15 +530,11 @@ calc_apparent (GWeatherInfo *info) static void gweather_info_reset (GWeatherInfo *info) { - g_free (info->forecast_attribution); - info->forecast_attribution = NULL; + g_clear_pointer (&info->forecast_attribution, g_free); free_forecast_list (info); - if (info->radar != NULL) { - g_object_unref (info->radar); - info->radar = NULL; - } + g_clear_object (&info->radar); info->update = 0; info->current_time = time(NULL); @@ -564,7 +560,6 @@ gweather_info_reset (GWeatherInfo *info) info->moonphase = 0; info->moonlatitude = 0; info->forecast_list = NULL; - info->radar = NULL; } static void @@ -591,8 +586,7 @@ gweather_info_init (GWeatherInfo *info) info->radar_url = g_settings_get_string (info->settings, RADAR_KEY); if (g_strcmp0 (info->radar_url, "") == 0) { - g_free (info->radar_url); - info->radar_url = NULL; + g_clear_pointer (&info->radar_url, g_free); } gweather_info_reset (info); @@ -761,11 +755,7 @@ gweather_info_dispose (GObject *object) g_clear_object (&info->session); free_forecast_list (info); - - if (info->radar != NULL) { - g_object_unref (info->radar); - info->radar = NULL; - } + g_clear_object (&info->radar); info->valid = FALSE; @@ -783,8 +773,7 @@ gweather_info_finalize (GObject *object) if (info->glocation) gweather_location_unref (info->glocation); - g_free (info->radar_url); - info->radar_url = NULL; + g_clear_pointer (&info->radar_url, g_free); g_free (info->forecast_attribution); |