diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-23 12:42:01 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-29 00:09:31 +0000 |
commit | 68961a169efc37039cd3fda334efb9ad9927444f (patch) | |
tree | 19365422501eacee57b4cc71722a8a5d8a54f323 /core/parse-xml.c | |
parent | 4cea7b49016923e3f9bb00b60976d7635907e038 (diff) | |
download | subsurface-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/parse-xml.c')
-rw-r--r-- | core/parse-xml.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/core/parse-xml.c b/core/parse-xml.c index 19a002568..c1d9fc2d5 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -968,6 +968,7 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu static void divinglog_place(char *place, uint32_t *uuid, struct parser_state *state) { char buffer[1024]; + struct dive_site *ds; snprintf(buffer, sizeof(buffer), "%s%s%s%s%s", @@ -976,8 +977,10 @@ static void divinglog_place(char *place, uint32_t *uuid, struct parser_state *st state->city ? state->city : "", state->country ? ", " : "", state->country ? state->country : ""); - *uuid = get_dive_site_uuid_by_name(buffer, NULL); - if (*uuid == 0) + ds = get_dive_site_by_name(buffer); + if (ds) + *uuid = ds->uuid; + else *uuid = create_dive_site(buffer, state->cur_dive->when); // TODO: capture the country / city info in the taxonomy instead @@ -1178,16 +1181,15 @@ static void gps_in_dive(char *buffer, struct dive *dive, struct parser_state *st parse_location(buffer, &location); if (uuid == 0) { // check if we have a dive site within 20 meters of that gps fix - uuid = get_dive_site_uuid_by_gps_proximity(&location, 20, &ds); + ds = get_dive_site_by_gps_proximity(&location, 20); if (ds) { // found a site nearby; in case it turns out this one had a different name let's // remember the original coordinates so we can create the correct dive site later state->cur_location = location; - dive->dive_site_uuid = uuid; + dive->dive_site_uuid = ds->uuid; } else { dive->dive_site_uuid = create_dive_site_with_gps("", &location, dive->when); - ds = get_dive_site_by_uuid(dive->dive_site_uuid); } } else { ds = get_dive_site_by_uuid(uuid); |