merge the formfield patch from ooo-build
[ooovba.git] / dmake / dbug / malloc / calloc.c
blob12cd933930e185cf2db0b40b1e015d04662b9097
1 /*
2 * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
3 * You may copy, distribute, and use this software as long as this
4 * copyright statement is not removed.
5 */
6 #include <stdio.h>
8 /*
9 * Function: calloc()
11 * Purpose: to allocate and nullify a data area
13 * Arguments: nelem - number of elements
14 * elsize - size of each element
16 * Returns: NULL - if malloc fails
17 * or pointer to allocated space
19 * Narrative: determine size of area to malloc
20 * malloc area.
21 * if malloc succeeds
22 * fill area with nulls
23 * return ptr to malloc'd region
25 #ifndef lint
26 static char rcs_header[] = "$Id: calloc.c,v 1.2 2006-07-25 10:07:11 rt Exp $";
27 #endif
29 char *
30 calloc(nelem,elsize)
31 unsigned int nelem;
32 unsigned int elsize;
34 char * malloc();
35 char * memset();
36 char * ptr;
37 unsigned int size;
39 size = elsize * nelem;
41 if( (ptr = malloc(size)) != NULL)
43 (void) memset(ptr,'\0',(int)size);
46 return(ptr);