From 98ada581866942a6da4fb6f056279a6188a1418d Mon Sep 17 00:00:00 2001 From: jtc Date: Wed, 13 Oct 1993 21:44:23 +0000 Subject: [PATCH] Split cfree() out of calloc.c. If a user compiling in a strict ANSI or strict POSIX environment uses his own function named cfree (which is legal, since cfree is not in a restricted namespace) and calloc, the link will fail due to the cfree in calloc.c. --- lib/libc/stdlib/Makefile.inc | 4 ++-- lib/libc/stdlib/calloc.c | 9 +------ lib/libc/stdlib/cfree.c | 46 ++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 lib/libc/stdlib/cfree.c diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc index 0e6dffffa112..9a75a996c7ce 100644 --- a/lib/libc/stdlib/Makefile.inc +++ b/lib/libc/stdlib/Makefile.inc @@ -1,10 +1,10 @@ # from: @(#)Makefile.inc 5.6 (Berkeley) 6/4/91 -# $Id: Makefile.inc,v 1.10 1993/10/09 00:08:02 jtc Exp $ +# $Id: Makefile.inc,v 1.11 1993/10/13 21:44:23 jtc Exp $ # stdlib sources .PATH: ${.CURDIR}/arch/${MACHINE}/stdlib ${.CURDIR}/stdlib -SRCS+= abort.c atexit.c atoi.c atol.c bsearch.c calloc.c exit.c \ +SRCS+= abort.c atexit.c atoi.c atol.c bsearch.c calloc.c cfree.c exit.c \ getenv.c getopt.c heapsort.c malloc.c multibyte.c \ putenv.c qsort.c radixsort.c rand.c random.c setenv.c strtod.c \ strtol.c strtoul.c system.c \ diff --git a/lib/libc/stdlib/calloc.c b/lib/libc/stdlib/calloc.c index 835ee48835c1..957f39cc1734 100644 --- a/lib/libc/stdlib/calloc.c +++ b/lib/libc/stdlib/calloc.c @@ -33,7 +33,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)calloc.c 5.6 (Berkeley) 2/23/91";*/ -static char *rcsid = "$Id: calloc.c,v 1.3 1993/08/26 00:47:55 jtc Exp $"; +static char *rcsid = "$Id: calloc.c,v 1.4 1993/10/13 21:44:25 jtc Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -51,10 +51,3 @@ calloc(num, size) bzero(p, size); return(p); } - -void -cfree(p) - void *p; -{ - (void)free(p); -} diff --git a/lib/libc/stdlib/cfree.c b/lib/libc/stdlib/cfree.c new file mode 100644 index 000000000000..6f14be7a71a2 --- /dev/null +++ b/lib/libc/stdlib/cfree.c @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)calloc.c 5.6 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: cfree.c,v 1.1 1993/10/13 21:44:27 jtc Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include + +void +cfree(p) + void *p; +{ + (void)free(p); +}