Annotation of 42BSD/lib/libc/gen/calloc.c, revision 1.1.1.1

1.1       root        1: /* @(#)calloc.c        4.1 (Berkeley) 12/21/80 */
                      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: cfree(p, num, size)
                     28: char *p;
                     29: unsigned num, size;
                     30: {
                     31:        free(p);
                     32: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.