Annotation of researchv10no/cmd/asd/alloc.c, revision 1.1

1.1     ! root        1: /*
        !             2:  *     storage allocator
        !             3:  *
        !             4:  *     calls malloc or realloc and aborts if unsuccessful
        !             5:  */
        !             6: 
        !             7: #include "asd.h"
        !             8: #include <stdio.h>
        !             9: 
        !            10: char *malloc(), *realloc();
        !            11: 
        !            12: char *
        !            13: alloc (n)
        !            14:        unsigned n;
        !            15: {
        !            16:        register char *p;
        !            17: 
        !            18:        p = malloc (n);
        !            19:        schk (p);
        !            20:        return p;
        !            21: }
        !            22: 
        !            23: char *
        !            24: ralloc (s, n)
        !            25:        char *s;
        !            26:        unsigned n;
        !            27: {
        !            28:        register char *p;
        !            29: 
        !            30:        if (s == NULL)
        !            31:                return alloc (n);
        !            32:        
        !            33:        p = realloc (s, n);
        !            34:        schk (p);
        !            35:        return p;
        !            36: }
        !            37: 
        !            38: /* return a copy of a string */
        !            39: char *
        !            40: copy (s)
        !            41:        register char *s;
        !            42: {
        !            43:        register char *r;
        !            44:        r = alloc ((unsigned) (strlen (s) + 1));
        !            45:        strcpy (r, s);
        !            46:        return r;
        !            47: }

unix.superglobalmegacorp.com

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