add estrndup()

This commit is contained in:
pooka 2007-07-01 21:41:16 +00:00
parent a5d1788b65
commit 060d8639e3
7 changed files with 30 additions and 12 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: shl.mi,v 1.392 2007/05/30 16:23:23 tls Exp $
# $NetBSD: shl.mi,v 1.393 2007/07/01 21:41:17 pooka Exp $
# Note: libtermcap and libtermlib are hardlinked and share the same version.
./lib/libc.so.12.150 base-sys-shlib
./lib/libcrypt.so.0.2 base-sys-shlib
@ -12,7 +12,7 @@
./lib/libradius.so.1.0 base-sys-shlib
./lib/libtermcap.so.0.6 base-sys-shlib
./lib/libtermlib.so.0.6 base-sys-shlib
./lib/libutil.so.7.13 base-sys-shlib
./lib/libutil.so.7.14 base-sys-shlib
./lib/libz.so.1.0 base-sys-shlib
./usr/lib/i18n/libBIG5.so.4.4 base-i18n-shlib
./usr/lib/i18n/libDECHanyu.so.4.4 base-i18n-shlib
@ -108,7 +108,7 @@
./usr/lib/libtermcap.so.0.6 base-sys-shlib
./usr/lib/libtermlib.so.0.6 base-sys-shlib
./usr/lib/libusbhid.so.1.0 base-sys-shlib
./usr/lib/libutil.so.7.13 base-sys-shlib
./usr/lib/libutil.so.7.14 base-sys-shlib
./usr/lib/libwrap.so.0.2 base-net-shlib
./usr/lib/libz.so.1.0 base-sys-shlib
./usr/lib/security/pam_afslog.so.0 base-sys-shlib kerberos,pam

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1038 2007/07/01 07:55:52 xtraeme Exp $
# $NetBSD: mi,v 1.1039 2007/07/01 21:41:16 pooka Exp $
./etc/mtree/set.comp comp-sys-root
./usr/bin/addr2line comp-debug-bin bfd
./usr/bin/ar comp-util-bin bfd
@ -4398,6 +4398,7 @@
./usr/share/man/cat3/errx.0 comp-c-catman .cat
./usr/share/man/cat3/esetfunc.0 comp-c-catman .cat
./usr/share/man/cat3/estrdup.0 comp-c-catman .cat
./usr/share/man/cat3/estrndup.0 comp-c-catman .cat
./usr/share/man/cat3/estrlcat.0 comp-c-catman .cat
./usr/share/man/cat3/estrlcpy.0 comp-c-catman .cat
./usr/share/man/cat3/etext.0 comp-c-catman .cat
@ -8739,6 +8740,7 @@
./usr/share/man/man3/errx.3 comp-c-man .man
./usr/share/man/man3/esetfunc.3 comp-c-man .man
./usr/share/man/man3/estrdup.3 comp-c-man .man
./usr/share/man/man3/estrndup.3 comp-c-man .man
./usr/share/man/man3/estrlcat.3 comp-c-man .man
./usr/share/man/man3/estrlcpy.3 comp-c-man .man
./usr/share/man/man3/etext.3 comp-c-man .man

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.h,v 1.45 2006/12/14 19:18:01 christos Exp $ */
/* $NetBSD: util.h,v 1.46 2007/07/01 21:41:16 pooka Exp $ */
/*-
* Copyright (c) 1995
@ -132,6 +132,7 @@ void (*esetfunc(void (*)(int, const char *, ...)))
size_t estrlcpy(char *, const char *, size_t);
size_t estrlcat(char *, const char *, size_t);
char *estrdup(const char *);
char *estrndup(const char *, size_t);
void *ecalloc(size_t, size_t);
void *emalloc(size_t);
void *erealloc(void *, size_t);

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.54 2006/12/14 19:18:01 christos Exp $
# $NetBSD: Makefile,v 1.55 2007/07/01 21:41:16 pooka Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes
@ -61,6 +61,7 @@ MLINKS+=efun.3 easprintf.3
MLINKS+=efun.3 estrlcpy.3
MLINKS+=efun.3 estrlcat.3
MLINKS+=efun.3 estrdup.3
MLINKS+=efun.3 estrndup.3
MLINKS+=efun.3 emalloc.3
MLINKS+=efun.3 ecalloc.3
MLINKS+=efun.3 erealloc.3

View File

@ -1,4 +1,4 @@
.\" $NetBSD: efun.3,v 1.4 2006/10/20 17:40:18 christos Exp $
.\" $NetBSD: efun.3,v 1.5 2007/07/01 21:41:16 pooka Exp $
.\"
.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -34,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 6, 2006
.Dd July 1, 2007
.Dt EFUN 3
.Os
.Sh NAME
@ -45,6 +45,7 @@
.Nm ecalloc ,
.Nm erealloc ,
.Nm estrdup ,
.Nm estrndup ,
.Nm estrlcat ,
.Nm estrlcpy ,
.Nm evasprintf
@ -67,6 +68,8 @@
.Fn erealloc "void *p" "size_t n"
.Ft char *
.Fn estrdup "const char *s"
.Ft char *
.Fn estrndup "const char *s" "size_t len"
.Ft size_t
.Fn estrlcat "char *dst" "const char *src" "size_t len"
.Ft size_t
@ -81,6 +84,7 @@ The
.Nm emalloc ,
.Nm erealloc ,
.Nm estrdup ,
.Nm estrndup ,
.Nm estrlcat ,
.Nm estrlcpy ,
and
@ -109,6 +113,7 @@ error handler will just call
.Xr malloc 3 ,
.Xr realloc 3 ,
.Xr strdup 3 ,
.Xr strndup 3 ,
.Xr strlcat 3 ,
.Xr strlcpy 3 ,
.Xr vasprintf 3

View File

@ -1,4 +1,4 @@
/* $NetBSD: efun.c,v 1.4 2006/09/27 16:20:03 christos Exp $ */
/* $NetBSD: efun.c,v 1.5 2007/07/01 21:41:16 pooka Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
#include <sys/cdefs.h>
#ifdef __RCSID
__RCSID("$NetBSD: efun.c,v 1.4 2006/09/27 16:20:03 christos Exp $");
__RCSID("$NetBSD: efun.c,v 1.5 2007/07/01 21:41:16 pooka Exp $");
#endif
#include <err.h>
@ -98,6 +98,15 @@ estrdup(const char *s)
return d;
}
char *
estrndup(const char *s, size_t len)
{
char *d = strndup(s, len);
if (d == NULL)
(*efunc)(1, "Cannot copy string");
return d;
}
void *
emalloc(size_t n)
{

View File

@ -1,5 +1,5 @@
# $NetBSD: shlib_version,v 1.43 2007/02/04 08:19:26 elad Exp $
# $NetBSD: shlib_version,v 1.44 2007/07/01 21:41:16 pooka Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=7
minor=13
minor=14