diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-05-05 04:08:43 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-05-05 04:08:43 +0200 |
commit | 0d23e46ce6891f2d836b9b7f2bf7d40d5d5eabfd (patch) | |
tree | efa2f124b7f1a45e3eca4559ca80d892b4a863a3 | |
parent | da76faaec7f09ae13d2f6623f47f69cddb19c14f (diff) |
Added usage of reallocarray()
-rw-r--r-- | FICS/gameproc.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/FICS/gameproc.c b/FICS/gameproc.c index 10531c6..f53518c 100644 --- a/FICS/gameproc.c +++ b/FICS/gameproc.c @@ -34,6 +34,8 @@ #include "stdinclude.h" #include "common.h" +#include <err.h> + #include "command.h" #include "comproc.h" #include "config.h" @@ -451,20 +453,25 @@ process_move(int p, char *command) garray[g].numHalfMoves++; if (garray[g].numHalfMoves > garray[g].examMoveListSize) { - size_t size; - garray[g].examMoveListSize += 20; // Allocate 20 // moves at a // time - size = (sizeof(move_t) * garray[g].examMoveListSize); - if (!garray[g].examMoveList) { - garray[g].examMoveList = rmalloc(size); + garray[g].examMoveList = + reallocarray(NULL, + sizeof(move_t), + garray[g].examMoveListSize); + if (garray[g].examMoveList == NULL) + err(1, "%s: reallocarray", __func__); + else + malloc_count++; } else { garray[g].examMoveList = - rrealloc(garray[g].examMoveList, - (sizeof(move_t) * - garray[g].examMoveListSize)); + reallocarray(garray[g].examMoveList, + sizeof(move_t), + garray[g].examMoveListSize); + if (garray[g].examMoveList == NULL) + err(1, "%s: reallocarray", __func__); } } |