00001 /* @(#)root/clib:$Id: mcalloc.c 20882 2007-11-19 11:31:26Z rdm $ */ 00002 /* Author: */ 00003 00004 /* Copyright (C) 1991, 1992 Free Software Foundation, Inc. 00005 This file is part of the GNU C Library. 00006 00007 The GNU C Library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public License as 00009 published by the Free Software Foundation; either version 2 of the 00010 License, or (at your option) any later version. 00011 00012 The GNU C Library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public 00018 License along with the GNU C Library; see the file COPYING.LIB. If 00019 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00020 Boston, MA 02111-1307, USA. */ 00021 00022 #include <string.h> /* Prototypes for memcpy, memmove, memset, etc */ 00023 00024 #include "mmprivate.h" 00025 00026 /* Allocate an array of NMEMB elements each SIZE bytes long. 00027 The entire array is initialized to zeros. */ 00028 00029 PTR 00030 mcalloc (md, nmemb, size) 00031 PTR md; 00032 register size_t nmemb; 00033 register size_t size; 00034 { 00035 register PTR result; 00036 00037 if ((result = mmalloc (md, nmemb * size)) != NULL) 00038 { 00039 memset (result, 0, nmemb * size); 00040 } 00041 return (result); 00042 } 00043 00044 /* When using this package, provide a version of malloc/realloc/free built 00045 on top of it, so that if we use the default sbrk() region we will not 00046 collide with another malloc package trying to do the same thing, if 00047 the application contains any "hidden" calls to malloc/realloc/free (such 00048 as inside a system library). */ 00049 00050 #ifndef NO_SBRK_MALLOC 00051 00052 PTR 00053 calloc (nmemb, size) 00054 size_t nmemb; 00055 size_t size; 00056 { 00057 return (mcalloc ((PTR) NULL, nmemb, size)); 00058 } 00059 00060 #endif