diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-02-23 11:05:19 +0100 |
---|---|---|
committer | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-07 00:13:34 +0200 |
commit | 2453d4fc1fa6c6109645853483839f1e3c87d4a8 (patch) | |
tree | c5555dfe98f91beed0cb99291b31e34ddb88c26c | |
parent | 64a5f10cfe9bf82bcab3efc99961bd20cf602df9 (diff) | |
download | subsurface-2453d4fc1fa6c6109645853483839f1e3c87d4a8.tar.gz |
core: introduce clone_cylinder() function
We have a clone_weightsystem function. For symmetry, introduce
a clone_cylinder() function so that we can more-or-less copy&paste
the weightsystem undo code for cylinder undo.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | core/equipment.c | 10 | ||||
-rw-r--r-- | core/equipment.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/core/equipment.c b/core/equipment.c index c9c0539c3..e96ce0d6a 100644 --- a/core/equipment.c +++ b/core/equipment.c @@ -137,12 +137,18 @@ void add_cloned_weightsystem_at(struct weightsystem_table *t, weightsystem_t ws) add_to_weightsystem_table(t, t->nr, clone_weightsystem(ws)); } +cylinder_t clone_cylinder(cylinder_t cyl) +{ + cylinder_t res = cyl; + res.type.description = copy_string(res.type.description); + return res; +} + /* Add a clone of a cylinder to the end of a cylinder table. * Cloned in means that the description-string is copied. */ void add_cloned_cylinder(struct cylinder_table *t, cylinder_t cyl) { - cyl.type.description = copy_string(cyl.type.description); - add_to_cylinder_table(t, t->nr, cyl); + add_to_cylinder_table(t, t->nr, clone_cylinder(cyl)); } bool same_weightsystem(weightsystem_t w1, weightsystem_t w2) diff --git a/core/equipment.h b/core/equipment.h index b62587447..74f04dfdf 100644 --- a/core/equipment.h +++ b/core/equipment.h @@ -75,6 +75,7 @@ extern weightsystem_t clone_weightsystem(weightsystem_t ws); extern void free_weightsystem(weightsystem_t ws); extern void copy_cylinder_types(const struct dive *s, struct dive *d); extern void add_cloned_weightsystem(struct weightsystem_table *t, weightsystem_t ws); +extern cylinder_t clone_cylinder(cylinder_t cyl); extern cylinder_t *add_empty_cylinder(struct cylinder_table *t); extern void add_cloned_cylinder(struct cylinder_table *t, cylinder_t cyl); extern cylinder_t *get_cylinder(const struct dive *d, int idx); |