summaryrefslogtreecommitdiffstats
path: root/core/load-git.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/load-git.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/load-git.c')
-rw-r--r--core/load-git.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/core/load-git.c b/core/load-git.c
index 84af37196..f74950248 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -159,9 +159,8 @@ static void parse_dive_gps(char *line, struct membuffer *str, void *_dive)
if (!ds) {
ds = get_dive_site_by_gps(&location, &dive_site_table);
if (!ds)
- dive->dive_site = create_dive_site_with_gps("", &location, &dive_site_table);
- else
- dive->dive_site = ds;
+ ds = create_dive_site_with_gps("", &location, &dive_site_table);
+ add_dive_to_dive_site(dive, ds);
} else {
if (dive_site_has_gps_location(ds) && !same_location(&ds->location, &location)) {
char *coords = printGPSCoordsC(&location);
@@ -183,9 +182,8 @@ static void parse_dive_location(char *line, struct membuffer *str, void *_dive)
if (!ds) {
ds = get_dive_site_by_name(name, &dive_site_table);
if (!ds)
- dive->dive_site = create_dive_site(name, &dive_site_table);
- else
- dive->dive_site = ds;
+ ds = create_dive_site(name, &dive_site_table);
+ add_dive_to_dive_site(dive, ds);
} else {
// we already had a dive site linked to the dive
if (empty_string(ds->name)) {
@@ -212,7 +210,7 @@ static void parse_dive_notes(char *line, struct membuffer *str, void *_dive)
{ UNUSED(line); struct dive *dive = _dive; dive->notes = get_utf8(str); }
static void parse_dive_divesiteid(char *line, struct membuffer *str, void *_dive)
-{ UNUSED(str); struct dive *dive = _dive; dive->dive_site = get_dive_site_by_uuid(get_hex(line), &dive_site_table); }
+{ UNUSED(str); struct dive *dive = _dive; add_dive_to_dive_site(dive, get_dive_site_by_uuid(get_hex(line), &dive_site_table)); }
/*
* We can have multiple tags in the membuffer. They are separated by