Implement XBoard memory command
[gnushogi.git] / gnushogi / commondsp.c
index e35698d..4cdc459 100644 (file)
@@ -1677,7 +1677,7 @@ InputCommand(char *command, int root)
                    "shogi"
 #endif
                 );
-            printf("debug=1 setboard=0 sigint=0 done=1\n");
+            printf("debug=1 setboard=0 sigint=0 memory=1 done=1\n");
         }
         else if (strcmp(s, ".") == 0)
         {   // periodic update request of analysis info: send stat01 info
@@ -1711,6 +1711,17 @@ InputCommand(char *command, int root)
         {
             ok = true;
         }
+#if ttblsz
+        else if (strcmp(s, "memory") == 0)
+        {
+            unsigned int mem, size, t = 1;
+            sscanf(sx, "memory %d", &mem);
+            if(mem > 2048) mem = 2048; /* prevent integer overflow for > 2GB hash */
+            size = (mem << 20) / sizeof(struct hashentry) - rehash;
+            while(t <= size/4) t <<= 1;
+            AllocateTT(t);
+        }
+#endif
         else if (strcmp(s, "go") == 0)
         {
             ok = true;