home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / libnix-0.8-src.lha / libnix-0.8 / sources / nix / stdlib / calloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  351 b   |  19 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void *calloc(unsigned long nmemb,unsigned long size)
  5. {
  6.   unsigned long l;
  7.   unsigned long *a;
  8.   void *b;
  9.   l=(nmemb*size+(sizeof(unsigned long)-1))&~(sizeof(unsigned long)-1);
  10.   a=(unsigned long *)(b=malloc(l));
  11.   if(b!=NULL)
  12.   {
  13.     do
  14.       *a++=0;
  15.     while((l-=sizeof(unsigned long))!=0);
  16.   }
  17.   return b;
  18. }
  19.