home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / gdb-4.12.tar.gz / gdb-4.12.tar / gdb-4.12 / mmalloc / mcalloc.c < prev    next >
C/C++ Source or Header  |  1994-02-03  |  2KB  |  54 lines

  1. /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <string.h>    /* Prototypes for memcpy, memmove, memset, etc */
  20.  
  21. #include "mmalloc.h"
  22.  
  23. /* Allocate an array of NMEMB elements each SIZE bytes long.
  24.    The entire array is initialized to zeros.  */
  25.  
  26. PTR
  27. mcalloc (md, nmemb, size)
  28.   PTR md;
  29.   register size_t nmemb;
  30.   register size_t size;
  31. {
  32.   register PTR result;
  33.  
  34.   if ((result = mmalloc (md, nmemb * size)) != NULL)
  35.     {
  36.       memset (result, 0, nmemb * size);
  37.     }
  38.   return (result);
  39. }
  40.  
  41. /* When using this package, provide a version of malloc/realloc/free built
  42.    on top of it, so that if we use the default sbrk() region we will not
  43.    collide with another malloc package trying to do the same thing, if
  44.    the application contains any "hidden" calls to malloc/realloc/free (such
  45.    as inside a system library). */
  46.  
  47. PTR
  48. calloc (nmemb, size)
  49.   size_t nmemb;
  50.   size_t size;
  51. {
  52.   return (mcalloc ((PTR) NULL, nmemb, size));
  53. }
  54.