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.
This commit is contained in:
jtc 1993-10-13 21:44:23 +00:00
parent aed90a8659
commit 98ada58186
3 changed files with 49 additions and 10 deletions

View File

@ -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 \

View File

@ -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 <stdlib.h>
@ -51,10 +51,3 @@ calloc(num, size)
bzero(p, size);
return(p);
}
void
cfree(p)
void *p;
{
(void)free(p);
}

46
lib/libc/stdlib/cfree.c Normal file
View File

@ -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 <stdlib.h>
void
cfree(p)
void *p;
{
(void)free(p);
}