Annotation of researchv10no/cmd/gre/egpos.c, revision 1.1

1.1     ! root        1: #include       "re.h"
        !             2: #include       "lre.h"
        !             3: #include       "hdr.h"
        !             4: 
        !             5: #ifndef        POSSTEP
        !             6: #define                POSSTEP         (8*1024)
        !             7: #endif
        !             8: 
        !             9: void
        !            10: eg_posinit(re_re *r)
        !            11: {
        !            12:        if(r->nposalloc <= 0)
        !            13:                r->nposalloc = POSSTEP;
        !            14:        r->posbase = (int *)egmalloc(r->nposalloc*sizeof(int), "posbase");
        !            15:        if (!r->posbase)
        !            16:                return;
        !            17:        r->posnext = 0;
        !            18: }
        !            19: 
        !            20: void
        !            21: eg_posset(re_re *r)
        !            22: {
        !            23:        r->posreset = r->posnext;
        !            24: }
        !            25: 
        !            26: eg_posalloc(re_re *r, int n)
        !            27: {
        !            28:        register j;
        !            29: 
        !            30:        if(n < 0){
        !            31:                r->posnext = r->posreset;
        !            32:                return(-1);
        !            33:        }
        !            34:        j = r->posnext;
        !            35:        r->posnext += n;
        !            36:        if(r->posnext >= r->nposalloc){
        !            37:                while((r->nposalloc < r->posnext) && (r->nposalloc < 256*1024))
        !            38:                        r->nposalloc *= 2;
        !            39:                if(r->nposalloc < r->posnext){
        !            40:                        r->nposalloc = (r->posnext+POSSTEP-1)/POSSTEP;
        !            41:                        r->nposalloc *= POSSTEP;
        !            42:                }
        !            43:                r->posbase = (int *)egrealloc((char *)r->posbase, r->nposalloc*sizeof(int), "posbase");
        !            44:                if (!r->posbase)
        !            45:                        return(-1);
        !            46:        }
        !            47:        return(j);
        !            48: }

unix.superglobalmegacorp.com

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