aboutsummaryrefslogtreecommitdiffstats
path: root/core/equipment.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-24 09:27:50 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-12-05 10:14:25 -0800
commite114522a44d67e03a2fa13e19c84a74cf5afca6d (patch)
tree2390a89ee0a02a2a497bf74e69d2dd8f8728e8af /core/equipment.c
parenta4c95fd8e8fa4b9a344ac437cfc0e01fc852f277 (diff)
downloadsubsurface-e114522a44d67e03a2fa13e19c84a74cf5afca6d.tar.gz
Cleanup: set description to null in free_[weightsystem|cylinder]
Currently, the caller is responsible for not reusing a freed weightsystem / cylinder or resetting the description field to null. This is very unfriendly. Set the description field to null, because that allows us to call free_* repeatedly on the same object. Use the new behavior to make the weightsystem model code a bit cleaner. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/equipment.c')
-rw-r--r--core/equipment.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/equipment.c b/core/equipment.c
index 07e468c1c..ebdff9772 100644
--- a/core/equipment.c
+++ b/core/equipment.c
@@ -26,11 +26,13 @@
void free_weightsystem(weightsystem_t ws)
{
free((void *)ws.description);
+ ws.description = NULL;
}
static void free_cylinder(cylinder_t c)
{
free((void *)c.type.description);
+ c.type.description = NULL;
}
void copy_weights(const struct weightsystem_table *s, struct weightsystem_table *d)