Book: replace *Offset macros with functions.
authorYann Dirson <ydirson@free.fr>
Fri, 21 Feb 2014 21:19:25 +0000 (22:19 +0100)
committerYann Dirson <ydirson@free.fr>
Sat, 22 Feb 2014 09:46:23 +0000 (10:46 +0100)
gnushogi/book.c

index 423749f..57758bb 100644 (file)
@@ -576,18 +576,17 @@ static ULONG currentoffset;
 
 #define MAXOFFSET(B) ((B.booksize - 1) * sizeof_gdxdata + sizeof_gdxadmin)
 
-#define HashOffset(hashkey, B) \
-{ \
-  currentoffset = ((ULONG)hashkey % B.booksize) \
-    * sizeof_gdxdata + sizeof_gdxadmin; \
+static void HashOffset(ULONG hashkey, struct gdxadmin *B)
+{
+    currentoffset = (hashkey % B->booksize) * sizeof_gdxdata + sizeof_gdxadmin;
 }
 
 
-#define NextOffset(B) \
-{ \
-  currentoffset += sizeof_gdxdata; \
-  if (currentoffset > B.maxoffset) \
-    currentoffset = sizeof_gdxadmin; \
+static void NextOffset(struct gdxadmin *B)
+{
+    currentoffset += sizeof_gdxdata;
+    if (currentoffset > B->maxoffset)
+        currentoffset = sizeof_gdxadmin;
 }
 
 
@@ -737,7 +736,7 @@ GetOpenings(void)
                              */
 
                             WriteData();
-                            HashOffset(bhashkey, B);
+                            HashOffset(bhashkey, &B);
                             first = true;
 
                             while (true)
@@ -779,7 +778,7 @@ GetOpenings(void)
                                     }
                                 }
 
-                                NextOffset(B);
+                                NextOffset(&B);
                                 first = false;
                             }
 
@@ -923,7 +922,7 @@ OpeningBook(unsigned short *hint)
         }
 
         x = 0;
-        HashOffset(hashkey, B);
+        HashOffset(hashkey, &B);
 #ifdef BOOKTEST
         printf("looking for book move, bhashbd = 0x%lx bhashkey = 0x%x\n",
                (ULONG)hashbd, HashValue(hashkey));
@@ -949,7 +948,7 @@ OpeningBook(unsigned short *hint)
                     break;
             }
 
-            NextOffset(B);
+            NextOffset(&B);
         }
 
 #ifdef BOOKTEST