at_wini also needs a pci_reserve() for the pci compatability device, if
[minix3.git] / lib / ansi / calloc.c
blobcccd79ab7a3b83e6933f81388339887f941ebd64
1 /* $Header$ */
2 #include <stdlib.h>
4 #define ALIGN(x) (((x) + (sizeof(size_t) - 1)) & ~(sizeof(size_t) - 1))
6 void *
7 calloc(size_t nelem, size_t elsize)
9 register char *p;
10 register size_t *q;
11 size_t size = ALIGN(nelem * elsize);
13 p = malloc(size);
14 if (p == NULL) return NULL;
15 q = (size_t *) (p + size);
16 while ((char *) q > p) *--q = 0;
17 return p;