From d3a7c5448fe166444980ed41757c9e03d83ece2f Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 23 Oct 2018 13:29:04 +0200 Subject: 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 --- core/divesite.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'core/divesite.c') 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); } -- cgit v1.2.3-70-g09d2