summaryrefslogtreecommitdiffstats
path: root/divesite.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-07-24 19:53:21 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-24 13:20:57 -0700
commit76fe262a0ffac68cf61da470772d2e370d9e019d (patch)
treea1f9e39bc1fcbc3e27e274e028da36e7ce7ff314 /divesite.c
parent0d2d91a28c1c10a0ee36c42610f618265a5f48be (diff)
downloadsubsurface-76fe262a0ffac68cf61da470772d2e370d9e019d.tar.gz
Allow creating new dive site with specific uuid
Test cases require deterministic results and thus we should allow uuid to be specified when needed. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divesite.c')
-rw-r--r--divesite.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/divesite.c b/divesite.c
index 4348461c6..4ffdcd78f 100644
--- a/divesite.c
+++ b/divesite.c
@@ -86,7 +86,7 @@ static uint32_t dive_site_getUniqId()
return id;
}
-struct dive_site *alloc_dive_site()
+struct dive_site *alloc_dive_site(uint32_t uuid)
{
int nr = dive_site_table.nr, allocated = dive_site_table.allocated;
struct dive_site **sites = dive_site_table.dive_sites;
@@ -104,7 +104,10 @@ struct dive_site *alloc_dive_site()
exit(1);
sites[nr] = ds;
dive_site_table.nr = nr + 1;
- ds->uuid = dive_site_getUniqId();
+ if (uuid)
+ ds->uuid = uuid;
+ else
+ ds->uuid = dive_site_getUniqId();
return ds;
}
@@ -157,7 +160,7 @@ void delete_dive_site(uint32_t id)
/* allocate a new site and add it to the table */
uint32_t create_dive_site(const char *name)
{
- struct dive_site *ds = alloc_dive_site();
+ struct dive_site *ds = alloc_dive_site(0);
ds->name = copy_string(name);
return ds->uuid;
@@ -166,7 +169,7 @@ uint32_t create_dive_site(const char *name)
/* same as before, but with GPS data */
uint32_t create_dive_site_with_gps(const char *name, degrees_t latitude, degrees_t longitude)
{
- struct dive_site *ds = alloc_dive_site();
+ struct dive_site *ds = alloc_dive_site(0);
ds->name = copy_string(name);
ds->latitude = latitude;
ds->longitude = longitude;