summaryrefslogtreecommitdiffstats
path: root/core/uemis-downloader.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-05 22:58:47 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commite2df38d868324f2a767d2109cdd8727acb866ca2 (patch)
tree614b560431d2c61f3f2b1e2f986c7806bd175ae9 /core/uemis-downloader.c
parentc22fd9f4fd6699333629b8acb1e9c135a9783082 (diff)
downloadsubsurface-e2df38d868324f2a767d2109cdd8727acb866ca2.tar.gz
Dive site: add dive site ref-counting
Instead of setting dive->dive_site directly, call the add_dive_to_dive_site() and unregister_dive_from_dive_site() functions. In the parser this turned out to be a bit tricky. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/uemis-downloader.c')
-rw-r--r--core/uemis-downloader.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c
index 76e6dcf09..593b94617 100644
--- a/core/uemis-downloader.c
+++ b/core/uemis-downloader.c
@@ -996,7 +996,8 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
int divespot_id = atoi(val);
if (divespot_id != -1) {
struct dive_site *ds = create_dive_site("from Uemis", devdata->sites);
- dive->dive_site = ds;
+ unregister_dive_from_dive_site(dive);
+ add_dive_to_dive_site(dive, ds);
uemis_mark_divelocation(dive->dc.diveid, divespot_id, ds);
}
#if UEMIS_DEBUG & 2
@@ -1182,7 +1183,8 @@ static void get_uemis_divespot(device_data_t *devdata, const char *mountpath, in
if (is_divespot_mappable(divespot_id)) {
struct dive_site *ds = get_dive_site_by_divespot_id(divespot_id);
- dive->dive_site = ds;
+ unregister_dive_from_dive_site(dive);
+ add_dive_to_dive_site(dive, ds);
} 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
@@ -1198,7 +1200,8 @@ static void get_uemis_divespot(device_data_t *devdata, const char *mountpath, in
/* if the uuid's are the same, the new site is a duplicate and can be deleted */
if (nds->uuid != ods->uuid) {
delete_dive_site(nds, devdata->sites);
- dive->dive_site = ods;
+ unregister_dive_from_dive_site(dive);
+ add_dive_to_dive_site(dive, ods);
}
}
add_to_divespot_mapping(divespot_id, dive->dive_site);