Module Name: src
Committed By: nia
Date: Fri Oct 29 11:42:34 UTC 2021
Modified Files:
src/games/sail: array.c
Log Message:
sail(6): convert realloc(x * y) to reallocarr
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/games/sail/array.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/sail/array.c
diff -u src/games/sail/array.c:1.1 src/games/sail/array.c:1.2
--- src/games/sail/array.c:1.1 Sun Mar 15 03:33:56 2009
+++ src/games/sail/array.c Fri Oct 29 11:42:34 2021
@@ -73,18 +73,14 @@ int
array_setsize(struct array *a, unsigned num)
{
unsigned newmax;
- void **newptr;
if (num > a->max) {
newmax = a->max;
while (num > newmax) {
newmax = newmax ? newmax*2 : 4;
}
- newptr = realloc(a->v, newmax*sizeof(*a->v));
- if (newptr == NULL) {
+ if (reallocarr(&a->v, newmax, sizeof(*a->v)) != 0)
return -1;
- }
- a->v = newptr;
a->max = newmax;
}
a->num = num;