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. --- range.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'range.c') diff --git a/range.c b/range.c index 8017f8d..dd7ecbc 100644 --- a/range.c +++ b/range.c @@ -170,18 +170,14 @@ static config_item *game_configure(const game_params *params) ret[0].name = "Width"; ret[0].type = C_STRING; - ret[0].sval = nfmtstr(10, "%d", params->w); - ret[0].ival = 0; + ret[0].u.string.sval = nfmtstr(10, "%d", params->w); ret[1].name = "Height"; ret[1].type = C_STRING; - ret[1].sval = nfmtstr(10, "%d", params->h); - ret[1].ival = 0; + ret[1].u.string.sval = nfmtstr(10, "%d", params->h); ret[2].name = NULL; ret[2].type = C_END; - ret[2].sval = NULL; - ret[2].ival = 0; return ret; } @@ -189,8 +185,8 @@ static config_item *game_configure(const game_params *params) static game_params *custom_params(const config_item *configuration) { game_params *ret = snew(game_params); - ret->w = atoi(configuration[0].sval); - ret->h = atoi(configuration[1].sval); + ret->w = atoi(configuration[0].u.string.sval); + ret->h = atoi(configuration[1].u.string.sval); return ret; } -- cgit v1.1