remove emalloc,ecalloc,erealloc,estrdup
This commit is contained in:
parent
d07e95dcc1
commit
c3d105f0a8
@ -6,8 +6,7 @@ SHLIB_MAJOR= 3
|
|||||||
SHLIB_MINOR= 0
|
SHLIB_MINOR= 0
|
||||||
CFLAGS+=-Wall -DLIBC_SCCS -I${.CURDIR}
|
CFLAGS+=-Wall -DLIBC_SCCS -I${.CURDIR}
|
||||||
CFLAGS+=-DINET6
|
CFLAGS+=-DINET6
|
||||||
SRCS= _secure_path.c auth.c ecalloc.c emalloc.c erealloc.c estrdup.c \
|
SRCS= _secure_path.c auth.c extattr.c fparseln.c login.c login_auth.c \
|
||||||
extattr.c fparseln.c login.c login_auth.c \
|
|
||||||
login_cap.c login_class.c login_crypt.c login_ok.c login_times.c \
|
login_cap.c login_class.c login_crypt.c login_ok.c login_times.c \
|
||||||
login_tty.c logout.c logwtmp.c property.c pty.c realhostname.c stub.c \
|
login_tty.c logout.c logwtmp.c property.c pty.c realhostname.c stub.c \
|
||||||
trimdomain.c uucplock.c
|
trimdomain.c uucplock.c
|
||||||
@ -19,8 +18,6 @@ MAN+= login.3 login_auth.3 login_tty.3 logout.3 logwtmp.3 pty.3 \
|
|||||||
_secure_path.3 uucplock.3 property.3 auth.3 realhostname.3 \
|
_secure_path.3 uucplock.3 property.3 auth.3 realhostname.3 \
|
||||||
realhostname_sa.3 trimdomain.3 fparseln.3
|
realhostname_sa.3 trimdomain.3 fparseln.3
|
||||||
MAN+= login.conf.5 auth.conf.5
|
MAN+= login.conf.5 auth.conf.5
|
||||||
MAN+= emalloc.3
|
|
||||||
|
|
||||||
MLINKS+= extattr.3 extattr_namespace_to_string.3 \
|
MLINKS+= extattr.3 extattr_namespace_to_string.3 \
|
||||||
extattr.3 extattr_string_to_namespace.3
|
extattr.3 extattr_string_to_namespace.3
|
||||||
MLINKS+= property.3 properties_read.3 property.3 properties_free.3
|
MLINKS+= property.3 properties_read.3 property.3 properties_free.3
|
||||||
@ -44,6 +41,5 @@ MLINKS+=login_ok.3 auth_ttyok.3 login_ok.3 auth_hostok.3 \
|
|||||||
MLINKS+=login_auth.3 auth_checknologin.3 login_auth.3 auth_cat.3
|
MLINKS+=login_auth.3 auth_checknologin.3 login_auth.3 auth_cat.3
|
||||||
MLINKS+=uucplock.3 uu_lock.3 uucplock.3 uu_lock_txfr.3 \
|
MLINKS+=uucplock.3 uu_lock.3 uucplock.3 uu_lock_txfr.3 \
|
||||||
uucplock.3 uu_unlock.3 uucplock.3 uu_lockerr.3
|
uucplock.3 uu_unlock.3 uucplock.3 uu_lockerr.3
|
||||||
MLINKS+=emalloc.3 ecalloc.3 emalloc.3 erealloc.3 emalloc.3 estrdup.3
|
|
||||||
|
|
||||||
.include <bsd.lib.mk>
|
.include <bsd.lib.mk>
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001 Assar Westerlund
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <err.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include "libutil.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Like calloc but never fails.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void *
|
|
||||||
ecalloc(size_t number, size_t size)
|
|
||||||
{
|
|
||||||
void *tmp = calloc(number, size);
|
|
||||||
|
|
||||||
if (tmp == NULL && number * size != 0)
|
|
||||||
errx(1, "calloc %lu failed", (unsigned long)number * size);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
.\" Copyright (c) 2001 Assar Westerlund
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\"
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" $FreeBSD$
|
|
||||||
.\"
|
|
||||||
.Dd June 17, 2001
|
|
||||||
.Os
|
|
||||||
.Dt EMALLOC 3
|
|
||||||
.Sh NAME
|
|
||||||
.Nm emalloc , ecalloc , erealloc , estrdup
|
|
||||||
.Nd non-failing memory allocation functions
|
|
||||||
.Sh LIBRARY
|
|
||||||
.Lb libutil
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Fd #include <sys/types.h>
|
|
||||||
.Fd #include <libutil.h>
|
|
||||||
.Ft void *
|
|
||||||
.Fn emalloc "size_t size"
|
|
||||||
.Ft void *
|
|
||||||
.Fn ecalloc "size_t number" "size_t size"
|
|
||||||
.Ft void *
|
|
||||||
.Fn erealloc "void *ptr" "size_t size"
|
|
||||||
.Ft char *
|
|
||||||
.Fn estrdup "const char *str"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
These functions work as
|
|
||||||
.Fn malloc ,
|
|
||||||
.Fn calloc ,
|
|
||||||
.Fn realloc ,
|
|
||||||
and
|
|
||||||
.Fn strdup ,
|
|
||||||
except that they never return
|
|
||||||
.Dv NULL ,
|
|
||||||
but instead call
|
|
||||||
.Fn errx
|
|
||||||
to abort the program if memory allocation fails.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr malloc 3 ,
|
|
||||||
.Xr calloc 3 ,
|
|
||||||
.Xr realloc 3 ,
|
|
||||||
.Xr strdup 3 ,
|
|
||||||
.Xr errx 3
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001 Assar Westerlund
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <err.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include "libutil.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Like malloc but never fails.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void *
|
|
||||||
emalloc(size_t sz)
|
|
||||||
{
|
|
||||||
void *tmp = malloc(sz);
|
|
||||||
|
|
||||||
if (tmp == NULL && sz != 0)
|
|
||||||
errx(1, "malloc %lu failed", (unsigned long)sz);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001 Assar Westerlund
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <err.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include "libutil.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Like realloc but never fails.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void *
|
|
||||||
erealloc(void *ptr, size_t sz)
|
|
||||||
{
|
|
||||||
void *tmp = realloc(ptr, sz);
|
|
||||||
|
|
||||||
if (tmp == NULL && sz != 0)
|
|
||||||
errx(1, "realloc %lu failed", (unsigned long)sz);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001 Assar Westerlund
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <err.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include "libutil.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Like strdup but never fails.
|
|
||||||
*/
|
|
||||||
|
|
||||||
char *
|
|
||||||
estrdup(const char *str)
|
|
||||||
{
|
|
||||||
void *tmp = strdup(str);
|
|
||||||
|
|
||||||
if (tmp == NULL)
|
|
||||||
errx(1, "strdup");
|
|
||||||
return tmp;
|
|
||||||
}
|
|
@ -76,10 +76,6 @@ int realhostname_sa __P((char *host, size_t hsize, struct sockaddr *addr,
|
|||||||
#ifdef _STDIO_H_ /* avoid adding new includes */
|
#ifdef _STDIO_H_ /* avoid adding new includes */
|
||||||
char *fparseln __P((FILE *, size_t *, size_t *, const char[3], int));
|
char *fparseln __P((FILE *, size_t *, size_t *, const char[3], int));
|
||||||
#endif
|
#endif
|
||||||
void *emalloc (size_t);
|
|
||||||
void *ecalloc (size_t, size_t);
|
|
||||||
void *erealloc (void *, size_t);
|
|
||||||
char *estrdup (const char *);
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#define UU_LOCK_INUSE (1)
|
#define UU_LOCK_INUSE (1)
|
||||||
|
Loading…
Reference in New Issue
Block a user