diff options
-rw-r--r-- | divesite.c | 15 | ||||
-rw-r--r-- | divesite.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/divesite.c b/divesite.c index 41d96de5d..cd8ee8a7d 100644 --- a/divesite.c +++ b/divesite.c @@ -169,6 +169,19 @@ void copy_dive_site(struct dive_site *orig, struct dive_site *copy) copy->notes = copy_string(orig->notes); copy->description = copy_string(orig->description); copy->uuid = orig->uuid; + copy->taxonomy.nr = orig->taxonomy.nr; + if (orig->taxonomy.category == NULL) { + free(copy->taxonomy.category); + copy->taxonomy.category = NULL; + } else { + if (copy->taxonomy.category == NULL) + copy->taxonomy.category = alloc_taxonomy(); + for (int i = 0; i < NR_CATEGORIES; i++) { + free((void *)copy->taxonomy.category[i].value); + copy->taxonomy.category[i] = orig->taxonomy.category[i]; + copy->taxonomy.category[i].value = copy_string(orig->taxonomy.category[i].value); + } + } } void clear_dive_site(struct dive_site *ds) @@ -182,4 +195,6 @@ void clear_dive_site(struct dive_site *ds) ds->latitude.udeg = 0; ds->longitude.udeg = 0; ds->uuid = 0; + ds->taxonomy.nr = 0; + free_taxonomy(ds->taxonomy.category); } diff --git a/divesite.h b/divesite.h index 71f3c0de7..306272e96 100644 --- a/divesite.h +++ b/divesite.h @@ -2,6 +2,7 @@ #define DIVESITE_H #include "units.h" +#include "taxonomy.h" #include <stdlib.h> #ifdef __cplusplus @@ -17,6 +18,7 @@ struct dive_site degrees_t latitude, longitude; char *description; char *notes; + struct taxonomy_data taxonomy; }; struct dive_site_table { |