Dive site: add dive site table parameter to dive site functions

To enable undo of dive site functions, it is crucial to work
with different dive site tables. Therefore add a dive site table
parameter to dive site functions. For now, always pass the global
dive site table. Thus, this commit shouldn't alter any functionality.

After this change, a simple search for dive_site_table reveals all
places where the global dive site table is accessed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-02-26 22:26:11 +01:00 committed by Dirk Hohndel
parent 36644dc9f7
commit f6e7bdc5ef
22 changed files with 118 additions and 118 deletions

View file

@ -225,7 +225,7 @@ void dive_site_end(struct parser_state *state)
state->cur_dive_site->taxonomy.category = NULL;
}
if (state->cur_dive_site->uuid) {
struct dive_site *ds = alloc_or_get_dive_site(state->cur_dive_site->uuid);
struct dive_site *ds = alloc_or_get_dive_site(state->cur_dive_site->uuid, &dive_site_table);
merge_dive_site(ds, state->cur_dive_site);
if (verbose > 3)
@ -419,7 +419,7 @@ void add_dive_site(char *ds_name, struct dive *dive, struct parser_state *state)
struct dive_site *ds = dive->dive_site;
if (!ds) {
// if the dive doesn't have a uuid, check if there's already a dive site by this name
ds = get_dive_site_by_name(buffer);
ds = get_dive_site_by_name(buffer, &dive_site_table);
}
if (ds) {
// we have a uuid, let's hope there isn't a different name
@ -430,11 +430,11 @@ void add_dive_site(char *ds_name, struct dive *dive, struct parser_state *state)
// but wait, we could have gotten this one based on GPS coords and could
// have had two different names for the same site... so let's search the other
// way around
struct dive_site *exact_match = get_dive_site_by_gps_and_name(buffer, &ds->location);
struct dive_site *exact_match = get_dive_site_by_gps_and_name(buffer, &ds->location, &dive_site_table);
if (exact_match) {
dive->dive_site = exact_match;
} else {
struct dive_site *newds = create_dive_site(buffer, dive->when);
struct dive_site *newds = create_dive_site(buffer, dive->when, &dive_site_table);
dive->dive_site = newds;
if (has_location(&state->cur_location)) {
// we started this uuid with GPS data, so lets use those
@ -449,7 +449,7 @@ void add_dive_site(char *ds_name, struct dive *dive, struct parser_state *state)
dive->dive_site = ds;
}
} else {
dive->dive_site = create_dive_site(buffer, dive->when);
dive->dive_site = create_dive_site(buffer, dive->when, &dive_site_table);
}
}
free(to_free);