shithub: puzzles

Download patch

ref: b0614e6da8f8a709e8fad797d7bb6ba05491ac79
parent: cd76bfb25f68bb320587bf85a059ee83c3d05239
author: Simon Tatham <anakin@pobox.com>
date: Mon Aug 22 05:27:52 EDT 2005

`Solve' operation on an already solved map without an aux_info was
returning NULL due to no moves being required, leading to a strange
error message. Trivial fix.

[originally from svn r6198]

--- a/map.c
+++ b/map.c
@@ -1563,8 +1563,10 @@
 	    return NULL;
 	}
 
-	retlen = retsize = 0;
-	ret = NULL;
+        retsize = 64;
+        ret = snewn(retsize, char);
+        strcpy(ret, "S");
+        retlen = 1;
 
 	for (i = 0; i < state->map->n; i++) {
             int len;
@@ -1574,8 +1576,7 @@
                 continue;
 	    assert(!state->map->immutable[i]);
 
-            len = sprintf(buf, "%s%d:%d", retlen ? ";" : "S;",
-			  colouring[i], i);
+            len = sprintf(buf, ";%d:%d", colouring[i], i);
             if (retlen + len >= retsize) {
                 retsize = retlen + len + 256;
                 ret = sresize(ret, retsize, char);