summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej S. Szmigiero <maciej.szmigiero@oracle.com>2023-01-05 23:12:00 +0100
committerMaciej S. Szmigiero <maciej.szmigiero@oracle.com>2023-01-05 23:29:16 +0100
commit2daf3fe97454bc33cb52834aef4321b431475859 (patch)
tree8019c1cd827e3b72e5b40995ad58bd4254ddb2fc
parentb46f8b6570f3304fca00f844403f1f4209e7ba58 (diff)
downloadgeoclue-2daf3fe97454bc33cb52834aef4321b431475859.tar.gz
Remove manual GStrv memory management
-rw-r--r--src/gclue-config.c4
-rw-r--r--src/gclue-location.c22
2 files changed, 11 insertions, 15 deletions
diff --git a/src/gclue-config.c b/src/gclue-config.c
index c6eb05e..8a2d361 100644
--- a/src/gclue-config.c
+++ b/src/gclue-config.c
@@ -126,7 +126,7 @@ load_app_configs (GClueConfig *config)
NULL };
GClueConfigPrivate *priv = config->priv;
gsize num_groups = 0, i;
- char **groups;
+ g_auto(GStrv) groups = NULL;
groups = g_key_file_get_groups (priv->key_file, &num_groups);
if (num_groups == 0)
@@ -187,8 +187,6 @@ error_out:
groups[i],
error->message);
}
-
- g_strfreev (groups);
}
static gboolean
diff --git a/src/gclue-location.c b/src/gclue-location.c
index 782d126..84062cb 100644
--- a/src/gclue-location.c
+++ b/src/gclue-location.c
@@ -606,11 +606,11 @@ gclue_location_new_full (gdouble latitude,
static GClueLocation *
gclue_location_create_from_gga (const char *gga, GError **error)
{
- GClueLocation *location = NULL;
+ GClueLocation *location;
gdouble latitude, longitude, accuracy, altitude;
gdouble hdop; /* Horizontal Dilution Of Precision */
guint64 timestamp;
- char **parts;
+ g_auto(GStrv) parts = NULL;
parts = g_strsplit (gga, ",", -1);
if (g_strv_length (parts) < 14) {
@@ -618,7 +618,7 @@ gclue_location_create_from_gga (const char *gga, GError **error)
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
"Invalid NMEA GGA sentence");
- goto out;
+ return NULL;
}
/* For syntax of GGA sentences:
@@ -632,7 +632,7 @@ gclue_location_create_from_gga (const char *gga, GError **error)
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
"Invalid NMEA GGA sentence");
- goto out;
+ return NULL;
}
altitude = parse_altitude_string (parts[9], parts[10]);
@@ -650,8 +650,6 @@ gclue_location_create_from_gga (const char *gga, GError **error)
if (altitude != GCLUE_LOCATION_ALTITUDE_UNKNOWN)
g_object_set (location, "altitude", altitude, NULL);
-out:
- g_strfreev (parts);
return location;
}
@@ -660,9 +658,10 @@ gclue_location_create_from_rmc (const char *rmc,
GClueLocation *prev_location,
GError **error)
{
- GClueLocation *location = NULL;
- char **parts = g_strsplit (rmc, ",", -1);
+ GClueLocation *location;
+ g_auto(GStrv) parts = NULL;
+ parts = g_strsplit (rmc, ",", -1);
if (g_strv_length (parts) < 13)
goto error;
@@ -707,15 +706,14 @@ gclue_location_create_from_rmc (const char *rmc,
NULL);
}
- goto out;
+ return location;
+
error:
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
"Invalid NMEA RMC sentence");
-out:
- g_strfreev (parts);
- return location;
+ return NULL;
}
/**