From 8815f77ea086ba474df051144098b80739a0f3ae Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 13 Oct 2018 11:52:59 +0200 Subject: Dive site: use own copy of taxonomy in dive-site-edit widget The dive-site-edit widget uses a copy of the to-be-edited site to compare with old values. Generally, this seems overkill (the original dive-site can be used for such a comparison). But one place where it can't simply be removed is the taxonomy, because the widget needs a place to store the unsaved data. Change the code to use an explicit taxonomy structure instead of the one provided in the copy. This should ultimately allow removal of the latter. Signed-off-by: Berthold Stoeger --- core/divesite.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'core/divesite.c') diff --git a/core/divesite.c b/core/divesite.c index e84ec1dcc..f634044c2 100644 --- a/core/divesite.c +++ b/core/divesite.c @@ -249,26 +249,6 @@ bool dive_site_is_empty(struct dive_site *ds) ds->longitude.udeg == 0); } -void copy_dive_site_taxonomy(struct dive_site *orig, struct dive_site *copy) -{ - if (orig->taxonomy.category == NULL) { - free_taxonomy(©->taxonomy); - } else { - if (copy->taxonomy.category == NULL) - copy->taxonomy.category = alloc_taxonomy(); - for (int i = 0; i < TC_NR_CATEGORIES; i++) { - if (i < copy->taxonomy.nr) { - free((void *)copy->taxonomy.category[i].value); - copy->taxonomy.category[i].value = NULL; - } - if (i < orig->taxonomy.nr) { - copy->taxonomy.category[i] = orig->taxonomy.category[i]; - copy->taxonomy.category[i].value = copy_string(orig->taxonomy.category[i].value); - } - } - copy->taxonomy.nr = orig->taxonomy.nr; - } -} void copy_dive_site(struct dive_site *orig, struct dive_site *copy) { free(copy->name); @@ -281,7 +261,7 @@ 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_dive_site_taxonomy(orig, copy); + copy_taxonomy(&orig->taxonomy, ©->taxonomy); } static void merge_string(char **a, char **b) -- cgit v1.2.3-70-g09d2