summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/dive.c2
-rw-r--r--core/divesite.c7
-rw-r--r--core/taxonomy.c5
3 files changed, 9 insertions, 5 deletions
diff --git a/core/dive.c b/core/dive.c
index 8cec50407..84d476958 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -670,7 +670,7 @@ void copy_cylinders(struct dive *s, struct dive *d, bool used_only)
memset(&d->cylinder[i], 0, sizeof(cylinder_t));
}
for (i = j = 0; i < MAX_CYLINDERS; i++) {
- if (!used_only || is_cylinder_used(s, i)) {
+ if (!used_only || is_cylinder_used(s, i) || s->cylinder[i].cylinder_use == NOT_USED) {
d->cylinder[j].type = s->cylinder[i].type;
d->cylinder[j].type.description = copy_string(s->cylinder[i].type.description);
d->cylinder[j].gasmix = s->cylinder[i].gasmix;
diff --git a/core/divesite.c b/core/divesite.c
index fd25bb965..3d5547905 100644
--- a/core/divesite.c
+++ b/core/divesite.c
@@ -314,10 +314,9 @@ void clear_dive_site(struct dive_site *ds)
free(ds->name);
free(ds->notes);
free(ds->description);
- free(ds->name);
- ds->name = 0;
- ds->notes = 0;
- ds->description = 0;
+ ds->name = NULL;
+ ds->notes = NULL;
+ ds->description = NULL;
ds->latitude.udeg = 0;
ds->longitude.udeg = 0;
ds->uuid = 0;
diff --git a/core/taxonomy.c b/core/taxonomy.c
index a6d829fa1..8776862d6 100644
--- a/core/taxonomy.c
+++ b/core/taxonomy.c
@@ -61,6 +61,11 @@ const char *taxonomy_get_country(struct taxonomy_data *t)
void taxonomy_set_country(struct taxonomy_data *t, const char *country, enum taxonomy_origin origin)
{
int idx = -1;
+
+ // make sure we have taxonomy data allocated
+ if (!t->category)
+ t->category = alloc_taxonomy();
+
for (int i = 0; i < t->nr; i++) {
if (t->category[i].category == TC_COUNTRY) {
idx = i;