calloc.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
  2. This library is free software; you can redistribute it and/or
  3. modify it under the terms of the GNU Library General Public License as
  4. published by the Free Software Foundation; either version 2 of the
  5. License, or (at your option) any later version.
  6. This library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Library General Public License for more details.
  10. You should have received a copy of the GNU Library General Public
  11. License along with this library; see the file COPYING.LIB. If
  12. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  13. Cambridge, MA 02139, USA.
  14. The author may be reached (Email) at the address mike@ai.mit.edu,
  15. or (US mail) as Mike Haertel c/o Free Software Foundation. */
  16. #ifndef _MALLOC_INTERNAL
  17. #define _MALLOC_INTERNAL
  18. #include <malloc.h>
  19. #endif
  20. /* Allocate an array of NMEMB elements each SIZE bytes long.
  21. The entire array is initialized to zeros. */
  22. __ptr_t
  23. calloc (nmemb, size)
  24. register __malloc_size_t nmemb;
  25. register __malloc_size_t size;
  26. {
  27. register __ptr_t result = malloc (nmemb * size);
  28. if (result != NULL)
  29. (void) memset (result, 0, nmemb * size);
  30. return result;
  31. }