#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;
}
-#define WriteAdmin() \
-{ \
- lseek(gfd, 0, SEEK_SET); \
- write(gfd, (char *)&ADMIN, sizeof_gdxadmin); \
+static void WriteAdmin(void)
+{
+ lseek(gfd, 0, SEEK_SET);
+ write(gfd, (char *)&ADMIN, sizeof_gdxadmin);
}
-#define WriteData() \
-{ \
- if (mustwrite ) \
- { \
- lseek(gfd, currentoffset, SEEK_SET); \
- write(gfd, (char *)&DATA, sizeof_gdxdata); \
- mustwrite = false; \
- } \
+static void WriteData(int *mustwrite)
+{
+ if (*mustwrite)
+ {
+ lseek(gfd, currentoffset, SEEK_SET);
+ write(gfd, (char *)&DATA, sizeof_gdxdata);
+ *mustwrite = false;
+ }
}
static int ReadAdmin(void)
* exist from some other opening.
*/
- WriteData();
- HashOffset(bhashkey, B);
+ WriteData(&mustwrite);
+ HashOffset(bhashkey, &B);
first = true;
while (true)
{
DATA.flags &= (~LASTMOVE);
mustwrite = true;
- WriteData();
+ WriteData(&mustwrite);
}
}
}
- NextOffset(B);
+ NextOffset(&B);
first = false;
}
{
/* reset for next opening */
games++;
- WriteData();
+ WriteData(&mustwrite);
RESET();
i = 0;
side = black;
}
}
- WriteData();
+ WriteData(&mustwrite);
fclose(fd);
/* write admin rec with counts */
ADMIN.bookcount = B.bookcount;
}
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));
break;
}
- NextOffset(B);
+ NextOffset(&B);
}
#ifdef BOOKTEST