Module Name:    src
Committed By:   kamil
Date:           Sun Jul 26 02:20:30 UTC 2015

Modified Files:
        src/distrib/sets/lists/comp: mi
        src/include: util.h
        src/lib/libutil: Makefile efun.3 efun.c

Log Message:
Add ereallocarr(3) to libutil

ereallocarr(3) wraps reallocarr(3) and embeds return status validation.

Older version reviewed by <riastradh> and <christos>


To generate a diff of this commit:
cvs rdiff -u -r1.1971 -r1.1972 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.66 -r1.67 src/include/util.h
cvs rdiff -u -r1.76 -r1.77 src/lib/libutil/Makefile
cvs rdiff -u -r1.11 -r1.12 src/lib/libutil/efun.3
cvs rdiff -u -r1.9 -r1.10 src/lib/libutil/efun.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1971 src/distrib/sets/lists/comp/mi:1.1972
--- src/distrib/sets/lists/comp/mi:1.1971	Tue Jul 21 03:12:50 2015
+++ src/distrib/sets/lists/comp/mi	Sun Jul 26 02:20:30 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1971 2015/07/21 03:12:50 knakahara Exp $
+#	$NetBSD: mi,v 1.1972 2015/07/26 02:20:30 kamil Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6422,6 +6422,7 @@
 ./usr/share/man/cat3/erase.0			comp-c-catman		.cat
 ./usr/share/man/cat3/erasechar.0		comp-c-catman		.cat
 ./usr/share/man/cat3/erealloc.0			comp-c-catman		.cat
+./usr/share/man/cat3/ereallocarr.0		comp-c-catman		.cat
 ./usr/share/man/cat3/erf.0			comp-c-catman		.cat
 ./usr/share/man/cat3/erfc.0			comp-c-catman		.cat
 ./usr/share/man/cat3/erfcf.0			comp-c-catman		.cat
@@ -13358,6 +13359,7 @@
 ./usr/share/man/html3/erase.html		comp-c-htmlman		html
 ./usr/share/man/html3/erasechar.html		comp-c-htmlman		html
 ./usr/share/man/html3/erealloc.html		comp-c-htmlman		html
+./usr/share/man/html3/ereallocarr.html		comp-c-htmlman		html
 ./usr/share/man/html3/erf.html			comp-c-htmlman		html
 ./usr/share/man/html3/erfc.html			comp-c-htmlman		html
 ./usr/share/man/html3/erfcf.html		comp-c-htmlman		html
@@ -20206,6 +20208,7 @@
 ./usr/share/man/man3/erase.3			comp-c-man		.man
 ./usr/share/man/man3/erasechar.3		comp-c-man		.man
 ./usr/share/man/man3/erealloc.3			comp-c-man		.man
+./usr/share/man/man3/ereallocarr.3		comp-c-man		.man
 ./usr/share/man/man3/erf.3			comp-c-man		.man
 ./usr/share/man/man3/erfc.3			comp-c-man		.man
 ./usr/share/man/man3/erfcf.3			comp-c-man		.man

Index: src/include/util.h
diff -u src/include/util.h:1.66 src/include/util.h:1.67
--- src/include/util.h:1.66	Sun Jan 18 18:10:01 2015
+++ src/include/util.h	Sun Jul 26 02:20:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.h,v 1.66 2015/01/18 18:10:01 christos Exp $	*/
+/*	$NetBSD: util.h,v 1.67 2015/07/26 02:20:30 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1995
@@ -152,6 +152,7 @@ uintmax_t	estrtou(const char *, int, uin
 void 		*ecalloc(size_t, size_t);
 void 		*emalloc(size_t);
 void 		*erealloc(void *, size_t);
+void 		ereallocarr(void *, size_t, size_t);
 struct __sFILE	*efopen(const char *, const char *);
 int	 	easprintf(char ** __restrict, const char * __restrict, ...)
 			__printflike(2, 3);

Index: src/lib/libutil/Makefile
diff -u src/lib/libutil/Makefile:1.76 src/lib/libutil/Makefile:1.77
--- src/lib/libutil/Makefile:1.76	Sun Jan 18 18:09:36 2015
+++ src/lib/libutil/Makefile	Sun Jul 26 02:20:30 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.76 2015/01/18 18:09:36 christos Exp $
+#	$NetBSD: Makefile,v 1.77 2015/07/26 02:20:30 kamil Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=	yes
@@ -82,6 +82,7 @@ MLINKS+=efun.3 estrtou.3
 MLINKS+=efun.3 emalloc.3
 MLINKS+=efun.3 ecalloc.3
 MLINKS+=efun.3 erealloc.3
+MLINKS+=efun.3 ereallocarr.3
 MLINKS+=efun.3 efopen.3
 MLINKS+=efun.3 evasprintf.3
 MLINKS+=stat_flags.3 string_to_flags.3

Index: src/lib/libutil/efun.3
diff -u src/lib/libutil/efun.3:1.11 src/lib/libutil/efun.3:1.12
--- src/lib/libutil/efun.3:1.11	Sun Jan 18 18:09:36 2015
+++ src/lib/libutil/efun.3	Sun Jul 26 02:20:30 2015
@@ -1,4 +1,4 @@
-.\"     $NetBSD: efun.3,v 1.11 2015/01/18 18:09:36 christos Exp $
+.\"     $NetBSD: efun.3,v 1.12 2015/07/26 02:20:30 kamil Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -37,6 +37,7 @@
 .Nm emalloc ,
 .Nm ecalloc ,
 .Nm erealloc ,
+.Nm ereallocarr ,
 .Nm estrdup ,
 .Nm estrndup ,
 .Nm estrlcat ,
@@ -61,6 +62,8 @@
 .Fn emalloc "size_t n"
 .Ft void *
 .Fn erealloc "void *p" "size_t n"
+.Ft void
+.Fn ereallocarr "void *p" "size_t n" "size_t s"
 .Ft char *
 .Fn estrdup "const char *s"
 .Ft char *
@@ -82,6 +85,7 @@ The
 .Fn ecalloc ,
 .Fn emalloc ,
 .Fn erealloc ,
+.Fn ereallocarr ,
 .Fn estrdup ,
 .Fn estrndup ,
 .Fn estrlcat ,
@@ -118,6 +122,7 @@ error handler will just call
 .Xr fopen 3 ,
 .Xr malloc 3 ,
 .Xr realloc 3 ,
+.Xr reallocarr 3 ,
 .Xr strdup 3 ,
 .Xr strlcat 3 ,
 .Xr strlcpy 3 ,
@@ -127,8 +132,9 @@ error handler will just call
 .Xr vasprintf 3
 .Sh HISTORY
 The
-.Fn estrtoi
-and
+.Fn estrtoi ,
 .Fn estrtou
+and
+.Fn ereallocarr
 functions were added in
 .Nx 8 .

Index: src/lib/libutil/efun.c
diff -u src/lib/libutil/efun.c:1.9 src/lib/libutil/efun.c:1.10
--- src/lib/libutil/efun.c:1.9	Sun Jan 18 18:09:36 2015
+++ src/lib/libutil/efun.c	Sun Jul 26 02:20:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: efun.c,v 1.9 2015/01/18 18:09:36 christos Exp $	*/
+/*	$NetBSD: efun.c,v 1.10 2015/07/26 02:20:30 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$NetBSD: efun.c,v 1.9 2015/01/18 18:09:36 christos Exp $");
+__RCSID("$NetBSD: efun.c,v 1.10 2015/07/26 02:20:30 kamil Exp $");
 #endif
 
 #include <err.h>
@@ -128,6 +128,16 @@ erealloc(void *p, size_t n)
 	return q;
 }
 
+void
+ereallocarr(void *p, size_t n, size_t s)
+{
+	int rv = reallocarr(p, n, s);
+	if (rv != 0) {
+		errno = rv;
+		(*efunc)(1, "Cannot re-allocate %zu * %zu bytes", n, s);
+	}
+}
+
 FILE *
 efopen(const char *p, const char *m)
 {

Reply via email to