diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-10-02 22:57:26 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-10-04 08:05:09 -0700 |
commit | de10fd4021f7fa7e203782df29456c09e07165e8 (patch) | |
tree | c59eda9916130ea5cc7581ea118a94c7e4bb6ca8 | |
parent | 9fd6b3eefbe9e1d34b4886d181ac9ba925936399 (diff) | |
download | subsurface-de10fd4021f7fa7e203782df29456c09e07165e8.tar.gz |
Add taxonomy copy helper function
We don't want to just be able to copy all of a dive site.
Sometimes we might want to be able to copy just the taxonomy.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/divesite.c | 28 | ||||
-rw-r--r-- | core/divesite.h | 1 |
2 files changed, 16 insertions, 13 deletions
diff --git a/core/divesite.c b/core/divesite.c index 2f199f596..159ac4d40 100644 --- a/core/divesite.c +++ b/core/divesite.c @@ -245,20 +245,8 @@ bool dive_site_is_empty(struct dive_site *ds) ds->longitude.udeg == 0; } -void copy_dive_site(struct dive_site *orig, struct dive_site *copy) +void copy_dive_site_taxonomy(struct dive_site *orig, struct dive_site *copy) { - free(copy->name); - free(copy->notes); - free(copy->country); - free(copy->description); - - copy->latitude = orig->latitude; - copy->longitude = orig->longitude; - copy->name = copy_string(orig->name); - copy->notes = copy_string(orig->notes); - copy->description = copy_string(orig->description); - copy->country = copy_string(orig->country); - copy->uuid = orig->uuid; if (orig->taxonomy.category == NULL) { free_taxonomy(©->taxonomy); } else { @@ -275,6 +263,20 @@ void copy_dive_site(struct dive_site *orig, struct dive_site *copy) copy->taxonomy.nr = orig->taxonomy.nr; } } +void copy_dive_site(struct dive_site *orig, struct dive_site *copy) +{ + free(copy->name); + free(copy->notes); + free(copy->description); + + copy->latitude = orig->latitude; + copy->longitude = orig->longitude; + copy->name = copy_string(orig->name); + copy->notes = copy_string(orig->notes); + copy->description = copy_string(orig->description); + copy->uuid = orig->uuid; + copy_dive_site_taxonomy(orig, copy); +} static void merge_string(char **a, char **b) { diff --git a/core/divesite.h b/core/divesite.h index dc041d355..452a27927 100644 --- a/core/divesite.h +++ b/core/divesite.h @@ -65,6 +65,7 @@ uint32_t get_dive_site_uuid_by_gps(degrees_t latitude, degrees_t longitude, stru uint32_t get_dive_site_uuid_by_gps_and_name(char *name, degrees_t latitude, degrees_t longitude); uint32_t get_dive_site_uuid_by_gps_proximity(degrees_t latitude, degrees_t longitude, int distance, struct dive_site **dsp); bool dive_site_is_empty(struct dive_site *ds); +void copy_dive_site_taxonomy(struct dive_site *orig, struct dive_site *copy); void copy_dive_site(struct dive_site *orig, struct dive_site *copy); void merge_dive_site(struct dive_site *a, struct dive_site *b); void clear_dive_site(struct dive_site *ds); |