Allow for trailing '\0' in game_text_format() in various games.
[sgt/puzzles] / misc.c
diff --git a/misc.c b/misc.c
index 58c4fb7..73b9a7b 100644 (file)
--- 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);
 }