summaryrefslogtreecommitdiffstats
path: root/core/divesite.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-23 13:29:04 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-29 00:09:31 +0000
commitd3a7c5448fe166444980ed41757c9e03d83ece2f (patch)
tree7a2a4f05b808705cd27845335876184f87243b5c /core/divesite.c
parentae6239bfec75df8a6795c2cc0017fcb0148e01e5 (diff)
downloadsubsurface-d3a7c5448fe166444980ed41757c9e03d83ece2f.tar.gz
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>
Diffstat (limited to 'core/divesite.c')
-rw-r--r--core/divesite.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/core/divesite.c b/core/divesite.c
index bef505814..f6e96e3c5 100644
--- a/core/divesite.c
+++ b/core/divesite.c
@@ -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);
}