Module Name: src
Committed By: nia
Date: Fri Oct 29 11:44:22 UTC 2021
Modified Files:
src/games/atc: grammar.y
Log Message:
atc(6): simplify reallocation logic
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/games/atc/grammar.y
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/atc/grammar.y
diff -u src/games/atc/grammar.y:1.12 src/games/atc/grammar.y:1.13
--- src/games/atc/grammar.y:1.12 Fri Jun 19 06:02:31 2015
+++ src/games/atc/grammar.y Fri Oct 29 11:44:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: grammar.y,v 1.12 2015/06/19 06:02:31 dholland Exp $ */
+/* $NetBSD: grammar.y,v 1.13 2021/10/29 11:44:22 nia Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -62,7 +62,7 @@
#if 0
static char sccsid[] = "@(#)grammar.y 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: grammar.y,v 1.12 2015/06/19 06:02:31 dholland Exp $");
+__RCSID("$NetBSD: grammar.y,v 1.13 2021/10/29 11:44:22 nia Exp $");
#endif
#endif /* not lint */
@@ -179,14 +179,8 @@ Bpoint:
'(' ConstOp ConstOp ')'
{
if (sp->num_beacons % REALLOC == 0) {
- if (sp->beacon == NULL)
- sp->beacon = malloc((sp->num_beacons
- + REALLOC) * sizeof (BEACON));
- else
- sp->beacon = realloc(sp->beacon,
- (sp->num_beacons + REALLOC) *
- sizeof (BEACON));
- if (sp->beacon == NULL)
+ if (reallocarr(&sp->beacon,
+ sp->num_beacons + REALLOC, sizeof(BEACON)) != 0)
return (yyerror("No memory available."));
}
sp->beacon[sp->num_beacons].x = $2;