Cleanup: use free_weightsystem function instead of explicit free

Instead of freeing internal data of the weightsystem structure,
call the free_weightsystem function (which has to be made extern
at first). This makes things more future-proof, should the
weightsystem struct ever be extended.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-11-03 23:14:35 +01:00 committed by Dirk Hohndel
parent dc67876c79
commit ab99ca85f1
3 changed files with 8 additions and 3 deletions

View file

@ -19,9 +19,13 @@
#include "subsurface-string.h"
#include "table.h"
static void free_weightsystem(weightsystem_t w)
/* Warning: this has strange semantics for C-code! Not the weightsystem object
* is freed, but the data it references. The object itself is passed in by value.
* This is due to the fact how the table macros work.
*/
void free_weightsystem(weightsystem_t ws)
{
free((void *)w.description);
free((void *)ws.description);
}
static void free_cylinder(cylinder_t c)