1: /*	@(#)calloc.c	2.1	SCCS id keyword	*/
   2: /*	calloc - allocate and clear memory block
   3: */
   4: #define CHARPERINT (sizeof(int)/sizeof(char))
   5: #define NULL 0
   6: 
   7: char *
   8: calloc(num, size)
   9: unsigned num, size;
  10: {
  11:     register char *mp;
  12:     char *malloc();
  13:     register int *q;
  14:     register m;
  15: 
  16:     num *= size;
  17:     mp = malloc(num);
  18:     if(mp == NULL)
  19:         return(NULL);
  20:     q = (int *) mp;
  21:     m = (num+CHARPERINT-1)/CHARPERINT;
  22:     while(--m>=0)
  23:         *q++ = 0;
  24:     return(mp);
  25: }
  26: 
  27: /*ARGSUSED*/
  28: cfree(p, num, size)
  29: char *p;
  30: unsigned num, size;
  31: {
  32:     free(p);
  33: }

Defined functions

calloc defined in line 7; used 107 times

Defined macros

CHARPERINT defined in line 4; used 2 times
  • in line 21(2)
NULL defined in line 5; used 2 times
Last modified: 1982-09-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 715
Valid CSS Valid XHTML 1.0 Strict