Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/sail sail(6): convert realloc(x * y) to reallocarr



details:   https://anonhg.NetBSD.org/src/rev/b532da8640ba
branches:  trunk
changeset: 1024582:b532da8640ba
user:      nia <nia%NetBSD.org@localhost>
date:      Fri Oct 29 11:42:34 2021 +0000

description:
sail(6): convert realloc(x * y) to reallocarr

diffstat:

 games/sail/array.c |  6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diffs (23 lines):

diff -r 77fd934761c9 -r b532da8640ba games/sail/array.c
--- a/games/sail/array.c        Fri Oct 29 11:40:23 2021 +0000
+++ b/games/sail/array.c        Fri Oct 29 11:42:34 2021 +0000
@@ -73,18 +73,14 @@
 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;



Home | Main Index | Thread Index | Old Index