summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/equipment.c10
-rw-r--r--core/equipment.h1
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);