calloc.c 602 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * libc/stdlib/malloc-zarg/calloc.c -- calloc function
  3. *
  4. * Copyright (C) 2002 NEC Corporation
  5. * Copyright (C) 2002 Miles Bader <miles@gnu.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU Lesser
  8. * General Public License. See the file COPYING.LIB in the main
  9. * directory of this archive for more details.
  10. *
  11. * Written by Miles Bader <miles@gnu.org>
  12. */
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include "malloc.h"
  16. void *
  17. calloc (size_t size, size_t num)
  18. {
  19. void *mem;
  20. size *= num;
  21. mem = malloc (size);
  22. if (mem)
  23. memset (mem, 0, size);
  24. return mem;
  25. }