From e114522a44d67e03a2fa13e19c84a74cf5afca6d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 24 Nov 2019 09:27:50 +0100 Subject: 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 --- core/equipment.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core') 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) -- cgit v1.2.3-70-g09d2