Skip to content

Commit a373ad5

Browse files
committed
sail(6): convert realloc(x * y) to reallocarr
1 parent dc9fa81 commit a373ad5

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

games/sail/array.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,14 @@ int
7373
array_setsize(struct array *a, unsigned num)
7474
{
7575
unsigned newmax;
76-
void **newptr;
7776

7877
if (num > a->max) {
7978
newmax = a->max;
8079
while (num > newmax) {
8180
newmax = newmax ? newmax*2 : 4;
8281
}
83-
newptr = realloc(a->v, newmax*sizeof(*a->v));
84-
if (newptr == NULL) {
82+
if (reallocarr(&a->v, newmax, sizeof(*a->v)) != 0)
8583
return -1;
86-
}
87-
a->v = newptr;
8884
a->max = newmax;
8985
}
9086
a->num = num;

0 commit comments

Comments
 (0)