~mdw
/
sgt
/
puzzles
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
After brainstorming with Gareth, we've decided that this is a much
[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"
#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);
}
}