X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/4efb3868c8a828892638f5490ef0402de22f1830..41184c244487c6f50cd174a0a913b02c5255aab9:/misc.c diff --git a/misc.c b/misc.c index 58c4fb7..73b9a7b 100644 --- a/misc.c +++ b/misc.c @@ -7,19 +7,12 @@ #include "puzzles.h" -int rand_upto(int limit) +void free_cfg(config_item *cfg) { - unsigned long divisor = RAND_MAX / (unsigned)limit; - unsigned long max = divisor * (unsigned)limit; - unsigned long n; + config_item *i; - assert(limit > 0); - - do { - n = rand(); - } while (n >= max); - - n /= divisor; - - return (int)n; + for (i = cfg; i->type != C_END; i++) + if (i->type == C_STRING) + sfree(i->sval); + sfree(cfg); }