[libgweather] location: Add helper to create GWeatherLocation struct



commit 2083210e9472854060973497f42741a1685c9af5
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Nov 30 12:34:02 2017 +0100

    location: Add helper to create GWeatherLocation struct
    
    https://bugzilla.gnome.org/show_bug.cgi?id=791066

 libgweather/gweather-location.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index ba3ead4..acafcc3 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -125,6 +125,19 @@ parse_coordinates (const char *coordinates,
 }
 
 static GWeatherLocation *
+location_new (GWeatherLocationLevel level)
+{
+    GWeatherLocation *loc;
+
+    loc = g_slice_new0 (GWeatherLocation);
+    loc->latitude = loc->longitude = DBL_MAX;
+    loc->level = level;
+    loc->ref_count = 1;
+
+    return loc;
+}
+
+static GWeatherLocation *
 location_new_from_xml (GWeatherParser *parser, GWeatherLocationLevel level,
                       GWeatherLocation *parent)
 {
@@ -135,12 +148,8 @@ location_new_from_xml (GWeatherParser *parser, GWeatherLocationLevel level,
     int tagtype;
     unsigned int i;
 
-    loc = g_slice_new0 (GWeatherLocation);
-    loc->latitude = loc->longitude = DBL_MAX;
+    loc = location_new (level);
     loc->parent = parent;
-    loc->level = level;
-    loc->ref_count = 1;
-    loc->msgctxt = NULL;
     if (level == GWEATHER_LOCATION_WORLD) {
        loc->metar_code_cache = g_hash_table_ref (parser->metar_code_cache);
        loc->country_code_cache = g_hash_table_ref (parser->country_code_cache);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]