summaryrefslogtreecommitdiffstats
path: root/core/load-git.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-23 12:42:01 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-29 00:09:31 +0000
commit68961a169efc37039cd3fda334efb9ad9927444f (patch)
tree19365422501eacee57b4cc71722a8a5d8a54f323 /core/load-git.c
parent4cea7b49016923e3f9bb00b60976d7635907e038 (diff)
downloadsubsurface-68961a169efc37039cd3fda334efb9ad9927444f.tar.gz
Dive site: return pointer to dive_site in get_dive_site_*()
As a first step in removing dive-site uuids, change the interface of the get_dive_site_*() functions to return pointers instead of uuids. This makes code a bit more complicated in places where the uuid is extracted afterwards (needed NULL check). Nevertheless, these places should disappear once pointers instead of uuids are stored in the dive-structures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/load-git.c')
-rw-r--r--core/load-git.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/load-git.c b/core/load-git.c
index 2040d2f70..f040f9de6 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -151,17 +151,17 @@ static int get_hex(const char *line)
static void parse_dive_gps(char *line, struct membuffer *str, void *_dive)
{
UNUSED(str);
- uint32_t uuid;
location_t location;
struct dive *dive = _dive;
struct dive_site *ds = get_dive_site_for_dive(dive);
parse_location(line, &location);
if (!ds) {
- uuid = get_dive_site_uuid_by_gps(&location, NULL);
- if (!uuid)
- uuid = create_dive_site_with_gps("", &location, dive->when);
- dive->dive_site_uuid = uuid;
+ ds = get_dive_site_by_gps(&location);
+ if (!ds)
+ dive->dive_site_uuid = create_dive_site_with_gps("", &location, dive->when);
+ else
+ dive->dive_site_uuid = ds->uuid;
} else {
if (dive_site_has_gps_location(ds) && !same_location(&ds->location, &location)) {
const char *coords = printGPSCoords(&location);
@@ -177,15 +177,15 @@ static void parse_dive_gps(char *line, struct membuffer *str, void *_dive)
static void parse_dive_location(char *line, struct membuffer *str, void *_dive)
{
UNUSED(line);
- uint32_t uuid;
char *name = get_utf8(str);
struct dive *dive = _dive;
struct dive_site *ds = get_dive_site_for_dive(dive);
if (!ds) {
- uuid = get_dive_site_uuid_by_name(name, NULL);
- if (!uuid)
- uuid = create_dive_site(name, dive->when);
- dive->dive_site_uuid = uuid;
+ ds = get_dive_site_by_name(name);
+ if (!ds)
+ dive->dive_site_uuid = create_dive_site(name, dive->when);
+ else
+ dive->dive_site_uuid = ds->uuid;
} else {
// we already had a dive site linked to the dive
if (empty_string(ds->name)) {