core: introduce set_cylinder() function

We have a set_weightsystem() function. For symmetry, introduce
a set_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>
This commit is contained in:
Berthold Stoeger 2020-02-23 11:38:53 +01:00
parent 1ca25ec039
commit f1e08fd470
2 changed files with 10 additions and 0 deletions

View file

@ -291,6 +291,15 @@ void remove_cylinder(struct dive *dive, int idx)
remove_from_cylinder_table(&dive->cylinders, idx);
}
// cyl is cloned.
void set_cylinder(struct dive *dive, int idx, cylinder_t cyl)
{
if (idx < 0 || idx >= dive->cylinders.nr)
return;
free_cylinder(dive->cylinders.cylinders[idx]);
dive->cylinders.cylinders[idx] = clone_cylinder(cyl);
}
void remove_weightsystem(struct dive *dive, int idx)
{
remove_from_weightsystem_table(&dive->weightsystems, idx);