summaryrefslogtreecommitdiffstats
path: root/core/uemis-downloader.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/uemis-downloader.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/uemis-downloader.c')
-rw-r--r--core/uemis-downloader.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c
index 18d8c280e..d80201fb5 100644
--- a/core/uemis-downloader.c
+++ b/core/uemis-downloader.c
@@ -124,15 +124,15 @@ static bool is_divespot_mappable(int divespot_id)
return false;
}
-static uint32_t get_dive_site_uuid_by_divespot_id(int divespot_id)
+static struct dive_site *get_dive_site_by_divespot_id(int divespot_id)
{
struct divespot_mapping *dm = divespot_mapping;
while (dm) {
if (dm->divespot_id == divespot_id)
- return dm->dive_site_uuid;
+ return get_dive_site_by_uuid(dm->dive_site_uuid);
dm = dm->next;
}
- return 0;
+ return NULL;
}
/* helper function to parse the Uemis data structures */
@@ -1177,18 +1177,19 @@ static void get_uemis_divespot(const char *mountpath, int divespot_id, struct di
struct dive_site *nds = get_dive_site_by_uuid(dive->dive_site_uuid);
if (is_divespot_mappable(divespot_id)) {
- dive->dive_site_uuid = get_dive_site_uuid_by_divespot_id(divespot_id);
+ struct dive_site *ds = get_dive_site_by_divespot_id(divespot_id);
+ dive->dive_site_uuid = ds ? ds->uuid : 0;
} else if (nds && nds->name && strstr(nds->name,"from Uemis")) {
if (load_uemis_divespot(mountpath, divespot_id)) {
/* get the divesite based on the diveid, this should give us
* the newly created site
*/
- struct dive_site *ods = NULL;
+ struct dive_site *ods;
/* with the divesite name we got from parse_dive, that is called on load_uemis_divespot
* we search all existing divesites if we have one with the same name already. The function
* returns the first found which is luckily not the newly created.
*/
- (void)get_dive_site_uuid_by_name(nds->name, &ods);
+ ods = get_dive_site_by_name(nds->name);
if (ods) {
/* if the uuid's are the same, the new site is a duplicate and can be deleted */
if (nds->uuid != ods->uuid) {