compiler/clib: #error if not cpu specific implementation of setjmp(), longjmp(),...
[AROS.git] / compiler / clib / calloc.c
blob0065b4ecab639a4c1ab171ca2e7de40cef17549e
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C 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
36 This function must not be used in a shared library or
37 in a threaded application.
39 EXAMPLE
41 BUGS
43 SEE ALSO
44 free(), malloc()
46 INTERNALS
48 ******************************************************************************/
50 ULONG * mem;
52 size *= count;
54 /* Allocate the memory */
55 mem = malloc (size);
57 if (mem)
58 memset (mem, 0, size);
60 return mem;
61 } /* calloc */