diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-03-06 19:26:19 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | 9e9821551fbb8dce3c4957ca5ea6f215c17a4d91 (patch) | |
tree | 1b4422a57b912c151fe5fb2144bb09304099574d /core | |
parent | e2df38d868324f2a767d2109cdd8727acb866ca2 (diff) | |
download | subsurface-9e9821551fbb8dce3c4957ca5ea6f215c17a4d91.tar.gz |
Dive site: use ref-counts to see if dive site is used
Checking for dive site usage is now simply checking the number
of dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/divesite.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/core/divesite.c b/core/divesite.c index 45a3221be..ed1587ce2 100644 --- a/core/divesite.c +++ b/core/divesite.c @@ -176,18 +176,16 @@ int nr_of_dives_at_dive_site(struct dive_site *ds, bool select_only) bool is_dive_site_used(struct dive_site *ds, bool select_only) { - int j; - bool found = false; - struct dive *d; - if (!ds) - return false; - for_each_dive(j, d) { - if (d->dive_site == ds && (!select_only || d->selected)) { - found = true; - break; - } + int i; + + if (!select_only) + return ds->dives.nr > 0; + + for (i = 0; i < ds->dives.nr; i++) { + if (ds->dives.dives[i]->selected) + return true; } - return found; + return false; } void free_dive_site(struct dive_site *ds) |