- Wrap change of entries in an InitChange/ExitChange pair (without this,
[AROS.git] / compiler / stdc / calloc.c
blob3e2b4562ea4438955b5a2feb602487e59f35c2b9
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function calloc().
6 */
8 #include <exec/types.h>
9 #include <string.h>
11 /*****************************************************************************
13 NAME */
14 #include <stdlib.h>
16 void * calloc (
18 /* SYNOPSIS */
19 size_t count,
20 size_t size)
22 /* FUNCTION
23 Allocate size bytes of memory, clears the memory (sets all bytes to
24 0) and returns the address of the first byte.
26 INPUTS
27 count - How many time size
28 size - How much memory to allocate.
30 RESULT
31 A pointer to the allocated memory or NULL. If you don't need the
32 memory anymore, you can pass this pointer to free(). If you don't,
33 the memory will be freed for you when the application exits.
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 free(), malloc()
44 INTERNALS
46 ******************************************************************************/
48 ULONG * mem;
50 size *= count;
52 /* Allocate the memory */
53 mem = malloc (size);
55 if (mem)
56 memset (mem, 0, size);
58 return mem;
59 } /* calloc */