Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add ereallocarr(3) to libutil
details: https://anonhg.NetBSD.org/src/rev/119b04366609
branches: trunk
changeset: 339506:119b04366609
user: kamil <kamil%NetBSD.org@localhost>
date: Sun Jul 26 02:20:30 2015 +0000
description:
Add ereallocarr(3) to libutil
ereallocarr(3) wraps reallocarr(3) and embeds return status validation.
Older version reviewed by <riastradh> and <christos>
diffstat:
distrib/sets/lists/comp/mi | 5 ++++-
include/util.h | 3 ++-
lib/libutil/Makefile | 3 ++-
lib/libutil/efun.3 | 12 +++++++++---
lib/libutil/efun.c | 14 ++++++++++++--
5 files changed, 29 insertions(+), 8 deletions(-)
diffs (156 lines):
diff -r 9461afe15667 -r 119b04366609 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Sun Jul 26 00:15:53 2015 +0000
+++ b/distrib/sets/lists/comp/mi Sun Jul 26 02:20:30 2015 +0000
@@ -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
diff -r 9461afe15667 -r 119b04366609 include/util.h
--- a/include/util.h Sun Jul 26 00:15:53 2015 +0000
+++ b/include/util.h Sun Jul 26 02:20:30 2015 +0000
@@ -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 @@
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);
diff -r 9461afe15667 -r 119b04366609 lib/libutil/Makefile
--- a/lib/libutil/Makefile Sun Jul 26 00:15:53 2015 +0000
+++ b/lib/libutil/Makefile Sun Jul 26 02:20:30 2015 +0000
@@ -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 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
diff -r 9461afe15667 -r 119b04366609 lib/libutil/efun.3
--- a/lib/libutil/efun.3 Sun Jul 26 00:15:53 2015 +0000
+++ b/lib/libutil/efun.3 Sun Jul 26 02:20:30 2015 +0000
@@ -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 @@
.Fn ecalloc ,
.Fn emalloc ,
.Fn erealloc ,
+.Fn ereallocarr ,
.Fn estrdup ,
.Fn estrndup ,
.Fn estrlcat ,
@@ -118,6 +122,7 @@
.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 @@
.Xr vasprintf 3
.Sh HISTORY
The
-.Fn estrtoi
+.Fn estrtoi ,
+.Fn estrtou
and
-.Fn estrtou
+.Fn ereallocarr
functions were added in
.Nx 8 .
diff -r 9461afe15667 -r 119b04366609 lib/libutil/efun.c
--- a/lib/libutil/efun.c Sun Jul 26 00:15:53 2015 +0000
+++ b/lib/libutil/efun.c Sun Jul 26 02:20:30 2015 +0000
@@ -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 @@
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)
{
Home |
Main Index |
Thread Index |
Old Index