summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2014-05-18 16:36:43 +0000
committerMarc Espie <espie@cvs.openbsd.org>2014-05-18 16:36:43 +0000
commit6fb714e881c53ffc1141b7a1f9bb2fcac4fbcc08 (patch)
tree673c8ea143a6c4198df6cdb06e87172e897abd36
parent42eb17fb849144c714f6ea8d7084077446a20c9c (diff)
use reallocarray
okay miod@, millert@
-rw-r--r--bin/chio/parse.y6
-rw-r--r--bin/ed/glbl.c6
-rw-r--r--bin/ed/undo.c4
3 files changed, 8 insertions, 8 deletions
diff --git a/bin/chio/parse.y b/bin/chio/parse.y
index 479e4dd7443..434e182aab0 100644
--- a/bin/chio/parse.y
+++ b/bin/chio/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.16 2013/11/25 12:51:10 benno Exp $ */
+/* $OpenBSD: parse.y,v 1.17 2014/05/18 16:36:41 espie Exp $ */
/*
* Copyright (c) 2006 Bob Beck <beck@openbsd.org>
@@ -113,8 +113,8 @@ changeroptsl : changeropts nl
changeropts : DRIVE STRING {
void *newp;
- if ((newp = realloc(curchanger->drives,
- (curchanger->drivecnt + 1) *
+ if ((newp = reallocarray(curchanger->drives,
+ curchanger->drivecnt + 1,
sizeof(curchanger->drives))) == NULL)
err(1, NULL);
curchanger->drives = newp;
diff --git a/bin/ed/glbl.c b/bin/ed/glbl.c
index 122e9c4038c..923e612acb4 100644
--- a/bin/ed/glbl.c
+++ b/bin/ed/glbl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: glbl.c,v 1.13 2012/12/04 02:40:48 deraadt Exp $ */
+/* $OpenBSD: glbl.c,v 1.14 2014/05/18 16:36:42 espie Exp $ */
/* $NetBSD: glbl.c,v 1.2 1995/03/21 09:04:41 cgd Exp $ */
/* glob.c: This file contains the global command routines for the ed line
@@ -149,8 +149,8 @@ set_active_node(line_t *lp)
int ti = active_size;
line_t **ts;
SPL1();
- if ((ts = (line_t **) realloc(active_list,
- (ti += MINBUFSZ) * sizeof(line_t **))) == NULL) {
+ if ((ts = reallocarray(active_list,
+ (ti += MINBUFSZ), sizeof(line_t **))) == NULL) {
perror(NULL);
seterrmsg("out of memory");
SPL0();
diff --git a/bin/ed/undo.c b/bin/ed/undo.c
index e827d3eb976..5686aaa3462 100644
--- a/bin/ed/undo.c
+++ b/bin/ed/undo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: undo.c,v 1.11 2012/12/04 02:40:48 deraadt Exp $ */
+/* $OpenBSD: undo.c,v 1.12 2014/05/18 16:36:42 espie Exp $ */
/* $NetBSD: undo.c,v 1.2 1995/03/21 09:04:52 cgd Exp $ */
/* undo.c: This file contains the undo routines for the ed line editor */
@@ -44,7 +44,7 @@ push_undo_stack(int type, int from, int to)
t = ustack;
if (u_p < usize ||
- (t = (undo_t *) realloc(ustack, (usize += USIZE) * sizeof(undo_t))) != NULL) {
+ (t = reallocarray(ustack, (usize += USIZE), sizeof(undo_t))) != NULL) {
ustack = t;
ustack[u_p].type = type;
ustack[u_p].t = get_addressed_line_node(to);