From de67801b0fd3dfa11777c1ef86cd617baf376b7b Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 1 Oct 2017 13:38:35 +0100 Subject: Use a proper union in struct config_item. This allows me to use different types for the mutable, dynamically allocated string value in a C_STRING control and the fixed constant list of option names in a C_CHOICES. --- untangle.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'untangle.c') diff --git a/untangle.c b/untangle.c index 4dd93be..4dfe208 100644 --- a/untangle.c +++ b/untangle.c @@ -185,13 +185,10 @@ static config_item *game_configure(const game_params *params) ret[0].name = "Number of points"; ret[0].type = C_STRING; sprintf(buf, "%d", params->n); - ret[0].sval = dupstr(buf); - ret[0].ival = 0; + ret[0].u.string.sval = dupstr(buf); ret[1].name = NULL; ret[1].type = C_END; - ret[1].sval = NULL; - ret[1].ival = 0; return ret; } @@ -200,7 +197,7 @@ static game_params *custom_params(const config_item *cfg) { game_params *ret = snew(game_params); - ret->n = atoi(cfg[0].sval); + ret->n = atoi(cfg[0].u.string.sval); return ret; } -- cgit v1.1