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>
This commit is contained in:
Berthold Stoeger 2019-03-06 19:26:19 +01:00 committed by Dirk Hohndel
parent e2df38d868
commit 9e9821551f

View file

@ -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) bool is_dive_site_used(struct dive_site *ds, bool select_only)
{ {
int j; int i;
bool found = false;
struct dive *d; if (!select_only)
if (!ds) return ds->dives.nr > 0;
return false;
for_each_dive(j, d) { for (i = 0; i < ds->dives.nr; i++) {
if (d->dive_site == ds && (!select_only || d->selected)) { if (ds->dives.dives[i]->selected)
found = true; return true;
break;
}
} }
return found; return false;
} }
void free_dive_site(struct dive_site *ds) void free_dive_site(struct dive_site *ds)