Dive site: return pointer to dive_site in create_dive_site_*()

This changes more of the dive-site interface to return pointers
instead of UUIDs. Currently, most call sites directly extract
UUIDs afterwards. Ultimately, the UUIDs will be generally replaced
by pointers, which will then simplify these callers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-10-23 13:29:04 +02:00 committed by Dirk Hohndel
parent ae6239bfec
commit d3a7c5448f
16 changed files with 35 additions and 36 deletions

View file

@ -203,16 +203,16 @@ uint32_t create_divesite_uuid(const char *name, timestamp_t divetime)
}
/* allocate a new site and add it to the table */
uint32_t create_dive_site(const char *name, timestamp_t divetime)
struct dive_site *create_dive_site(const char *name, timestamp_t divetime)
{
uint32_t uuid = create_divesite_uuid(name, divetime);
struct dive_site *ds = alloc_or_get_dive_site(uuid);
ds->name = copy_string(name);
return uuid;
return ds;
}
/* same as before, but with current time if no current_dive is present */
uint32_t create_dive_site_from_current_dive(const char *name)
struct dive_site *create_dive_site_from_current_dive(const char *name)
{
if (current_dive != NULL) {
return create_dive_site(name, current_dive->when);
@ -225,14 +225,14 @@ uint32_t create_dive_site_from_current_dive(const char *name)
}
/* same as before, but with GPS data */
uint32_t create_dive_site_with_gps(const char *name, const location_t *loc, timestamp_t divetime)
struct dive_site *create_dive_site_with_gps(const char *name, const location_t *loc, timestamp_t divetime)
{
uint32_t uuid = create_divesite_uuid(name, divetime);
struct dive_site *ds = alloc_or_get_dive_site(uuid);
ds->name = copy_string(name);
ds->location = *loc;
return ds->uuid;
return ds;
}
/* a uuid is always present - but if all the other fields are empty, the dive site is pointless */
@ -330,7 +330,7 @@ void merge_dive_sites(uint32_t ref, uint32_t* uuids, int count)
mark_divelist_changed(true);
}
uint32_t find_or_create_dive_site_with_name(const char *name, timestamp_t divetime)
struct dive_site *find_or_create_dive_site_with_name(const char *name, timestamp_t divetime)
{
int i;
struct dive_site *ds;
@ -339,7 +339,7 @@ uint32_t find_or_create_dive_site_with_name(const char *name, timestamp_t diveti
break;
}
if (ds)
return ds->uuid;
return ds;
return create_dive_site(name, divetime);
}