diff options
-rw-r--r-- | lib/libutil/Makefile | 6 | ||||
-rw-r--r-- | lib/libutil/ecalloc.c | 49 | ||||
-rw-r--r-- | lib/libutil/emalloc.3 | 64 | ||||
-rw-r--r-- | lib/libutil/emalloc.c | 49 | ||||
-rw-r--r-- | lib/libutil/erealloc.c | 49 | ||||
-rw-r--r-- | lib/libutil/estrdup.c | 50 | ||||
-rw-r--r-- | lib/libutil/libutil.h | 4 |
7 files changed, 1 insertions, 270 deletions
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile index d310df5..13c54d6 100644 --- a/lib/libutil/Makefile +++ b/lib/libutil/Makefile @@ -6,8 +6,7 @@ SHLIB_MAJOR= 3 SHLIB_MINOR= 0 CFLAGS+=-Wall -DLIBC_SCCS -I${.CURDIR} CFLAGS+=-DINET6 -SRCS= _secure_path.c auth.c ecalloc.c emalloc.c erealloc.c estrdup.c \ - extattr.c fparseln.c login.c login_auth.c \ +SRCS= _secure_path.c 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_tty.c logout.c logwtmp.c property.c pty.c realhostname.c stub.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 \ realhostname_sa.3 trimdomain.3 fparseln.3 MAN+= login.conf.5 auth.conf.5 -MAN+= emalloc.3 - MLINKS+= extattr.3 extattr_namespace_to_string.3 \ extattr.3 extattr_string_to_namespace.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+=uucplock.3 uu_lock.3 uucplock.3 uu_lock_txfr.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> diff --git a/lib/libutil/ecalloc.c b/lib/libutil/ecalloc.c deleted file mode 100644 index ce778df..0000000 --- a/lib/libutil/ecalloc.c +++ /dev/null @@ -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; -} diff --git a/lib/libutil/emalloc.3 b/lib/libutil/emalloc.3 deleted file mode 100644 index f087e86..0000000 --- a/lib/libutil/emalloc.3 +++ /dev/null @@ -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 diff --git a/lib/libutil/emalloc.c b/lib/libutil/emalloc.c deleted file mode 100644 index 29dd3da..0000000 --- a/lib/libutil/emalloc.c +++ /dev/null @@ -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; -} diff --git a/lib/libutil/erealloc.c b/lib/libutil/erealloc.c deleted file mode 100644 index 6c3e2a1..0000000 --- a/lib/libutil/erealloc.c +++ /dev/null @@ -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; -} diff --git a/lib/libutil/estrdup.c b/lib/libutil/estrdup.c deleted file mode 100644 index 4dfeac1..0000000 --- a/lib/libutil/estrdup.c +++ /dev/null @@ -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; -} diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h index 758136e..aa82caa 100644 --- a/lib/libutil/libutil.h +++ b/lib/libutil/libutil.h @@ -76,10 +76,6 @@ int realhostname_sa __P((char *host, size_t hsize, struct sockaddr *addr, #ifdef _STDIO_H_ /* avoid adding new includes */ char *fparseln __P((FILE *, size_t *, size_t *, const char[3], int)); #endif -void *emalloc (size_t); -void *ecalloc (size_t, size_t); -void *erealloc (void *, size_t); -char *estrdup (const char *); __END_DECLS #define UU_LOCK_INUSE (1) |