chiark / gitweb /
Fix a memory leak in Range's find_errors.
[sgt-puzzles.git] / range.c
diff --git a/range.c b/range.c
index 4e33cae201f0fd4501d4b0c9ce27ae4d5d0289fb..4347f7697d1c25f84ca0d3322ffe49e57c35c7e2 100644 (file)
--- a/range.c
+++ b/range.c
@@ -15,7 +15,8 @@
  *    cell.  Then n must equal h + v - 1.
  */
 
-/* example instance with its encoding:
+/* example instance with its encoding and textual representation, both
+ * solved and unsolved (made by thegame.solve and thegame.text_format)
  *
  * +--+--+--+--+--+--+--+
  * |  |  |  |  | 7|  |  |
  * +--+--+--+--+--+--+--+
  *
  * 7x7:d7b3e8e5c7a7c13e4d8b4d
+ *
+ * +--+--+--+--+--+--+--+
+ * |..|..|..|..| 7|..|..|
+ * +--+--+--+--+--+--+--+
+ * | 3|..|##|..|##|..| 8|
+ * +--+--+--+--+--+--+--+
+ * |##|..|..|##|..| 5|..|
+ * +--+--+--+--+--+--+--+
+ * |..|..| 7|..| 7|##|..|
+ * +--+--+--+--+--+--+--+
+ * |..|13|..|..|..|..|..|
+ * +--+--+--+--+--+--+--+
+ * | 4|..|##|..|##|..| 8|
+ * +--+--+--+--+--+--+--+
+ * |##|..| 4|..|..|##|..|
+ * +--+--+--+--+--+--+--+
  */
 
 #include <stdio.h>
@@ -1150,7 +1167,7 @@ static char *game_text_format(const game_state *state)
     cellsize = 0; /* or may be used uninitialized */
 
     for (c = 0; c < w; ++c) {
-        for (r = 1; r < h; ++r) {
+        for (r = 0; r < h; ++r) {
             puzzle_size k = state->grid[idx(r, c, w)];
             int d;
             for (d = 0; k; k /= 10, ++d);
@@ -1434,7 +1451,7 @@ static int find_errors(const game_state *state, int *report)
         int biggest, canonical;
 
         if (!report) {
-            printf("dfs fail at %d\n", any_white_cell);
+            sfree(dsf);
             goto found_error;
         }