Source-Changes-HG archive

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

[src/trunk]: src/games/cgram cgram(6): realloc(x * y) -> reallocarr



details:   https://anonhg.NetBSD.org/src/rev/90b1db2cf8c6
branches:  trunk
changeset: 1024584:90b1db2cf8c6
user:      nia <nia%NetBSD.org@localhost>
date:      Fri Oct 29 11:45:39 2021 +0000

description:
cgram(6): realloc(x * y) -> reallocarr

diffstat:

 games/cgram/cgram.c |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (28 lines):

diff -r f8b9a56bb640 -r 90b1db2cf8c6 games/cgram/cgram.c
--- a/games/cgram/cgram.c       Fri Oct 29 11:44:22 2021 +0000
+++ b/games/cgram/cgram.c       Fri Oct 29 11:45:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgram.c,v 1.25 2021/05/28 03:55:45 dholland Exp $ */
+/* $NetBSD: cgram.c,v 1.26 2021/10/29 11:45:39 nia Exp $ */
 
 /*-
  * Copyright (c) 2013, 2021 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.c,v 1.25 2021/05/28 03:55:45 dholland Exp $");
+__RCSID("$NetBSD: cgram.c,v 1.26 2021/10/29 11:45:39 nia Exp $");
 #endif
 
 #include <assert.h>
@@ -154,8 +154,7 @@
 stringarray_add(struct stringarray *a, struct string *s)
 {
        size_t num = a->num++;
-       a->v = realloc(a->v, a->num * sizeof a->v[0]);
-       if (a->v == NULL)
+       if (reallocarr(&a->v, a->num, sizeof(a->v[0])) != 0)
                errx(1, "Out of memory");
        a->v[num] = *s;
 }



Home | Main Index | Thread Index | Old Index