summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/divesite.c15
-rw-r--r--core/divesite.h1
-rw-r--r--core/parse.c5
3 files changed, 13 insertions, 8 deletions
diff --git a/core/divesite.c b/core/divesite.c
index f634044c2..c41b18220 100644
--- a/core/divesite.c
+++ b/core/divesite.c
@@ -40,7 +40,6 @@ uint32_t get_dive_site_uuid_by_gps(degrees_t latitude, degrees_t longitude, stru
return 0;
}
-
/* to avoid a bug where we have two dive sites with different name and the same GPS coordinates
* and first get the gps coordinates (reading a V2 file) and happen to get back "the other" name,
* this function allows us to verify if a very specific name/GPS combination already exists */
@@ -167,16 +166,22 @@ bool is_dive_site_used(uint32_t uuid, bool select_only)
return found;
}
+void free_dive_site(struct dive_site *ds)
+{
+ free(ds->name);
+ free(ds->notes);
+ free(ds->description);
+ free_taxonomy(&ds->taxonomy);
+ free(ds);
+}
+
void delete_dive_site(uint32_t id)
{
int nr = dive_site_table.nr;
for (int i = 0; i < nr; i++) {
struct dive_site *ds = get_dive_site(i);
if (ds->uuid == id) {
- free(ds->name);
- free(ds->notes);
- free_taxonomy(&ds->taxonomy);
- free(ds);
+ free_dive_site(ds);
if (nr - 1 > i)
memmove(&dive_site_table.dive_sites[i],
&dive_site_table.dive_sites[i+1],
diff --git a/core/divesite.h b/core/divesite.h
index b38ef5c28..f5fe1dbd5 100644
--- a/core/divesite.h
+++ b/core/divesite.h
@@ -56,6 +56,7 @@ void dive_site_table_sort();
struct dive_site *alloc_or_get_dive_site(uint32_t uuid);
int nr_of_dives_at_dive_site(uint32_t uuid, bool select_only);
bool is_dive_site_used(uint32_t uuid, bool select_only);
+void free_dive_site(struct dive_site *ds);
void delete_dive_site(uint32_t id);
uint32_t create_dive_site(const char *name, timestamp_t divetime);
uint32_t create_dive_site_from_current_dive(const char *name);
diff --git a/core/parse.c b/core/parse.c
index 054db156f..067008970 100644
--- a/core/parse.c
+++ b/core/parse.c
@@ -228,8 +228,7 @@ void dive_site_end(void)
if (verbose > 3)
printf("completed dive site uuid %x8 name {%s}\n", ds->uuid, ds->name);
}
- free_taxonomy(&cur_dive_site->taxonomy);
- free(cur_dive_site);
+ free_dive_site(cur_dive_site);
cur_dive_site = NULL;
}
@@ -254,7 +253,7 @@ void dive_end(void)
if (!cur_dive)
return;
if (!is_dive())
- free(cur_dive);
+ free_dive(cur_dive);
else
record_dive_to_table(cur_dive, target_table);
cur_dive = NULL;