diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-05-04 12:27:38 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-05-04 12:27:38 +0200 |
commit | 106483f895e528fb969ff84433c33ecfa74eb45c (patch) | |
tree | e6bc5f03384276aec16042b7f8802523142e5dd0 /FICS | |
parent | f66058a68cb44e10446f8bc196bc8adc1993bf79 (diff) |
Revised ReadV1Moves()
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/gamedb.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/FICS/gamedb.c b/FICS/gamedb.c index fb788d8..3f7e64e 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -1001,16 +1001,21 @@ ReadOneV1Move(FILE *fp, move_t *m) strcat(m->algString, "+"); } -int ReadV1Moves(game *g, FILE * fp) +int +ReadV1Moves(game *g, FILE *fp) { - int i; + g->moveListSize = g->numHalfMoves; + g->moveList = reallocarray(NULL, sizeof(move_t), g->moveListSize); - g->moveListSize = g->numHalfMoves; - g->moveList = (move_t *) rmalloc(sizeof(move_t) * g->moveListSize); - for (i = 0; i < g->numHalfMoves; i++) { - ReadOneV1Move(fp, &g->moveList[i]); - } - return 0; + if (g->moveList == NULL) + err(1, "%s: reallocarray", __func__); + else + malloc_count++; + + for (int i = 0; i < g->numHalfMoves; i++) + ReadOneV1Move(fp, &g->moveList[i]); + + return 0; } int |