Annotation of researchv9/jerq/src/lib/C/_vec.c, revision 1.1

1.1     ! root        1: typedef void* PV;
        !             2: typedef void (*PF)(PV);
        !             3: typedef void (*PFI)(PV,int);
        !             4: 
        !             5: PV _vec_new(PV op, int n, int sz, PV f)
        !             6: /*
        !             7:        allocate a vector of "n" elements of size "sz"
        !             8:        and initialize each by a call of "f"
        !             9: */
        !            10: {
        !            11:        if (op == 0) op = PV( new char[n*sz] );
        !            12:        register char* p = (char*) op;
        !            13:        if (f) for (register int i=0; i<n; i++) ( *PF(f) )( PV(p+i*sz) );
        !            14:        return PV(p);
        !            15: }
        !            16: 
        !            17: void _vec_delete(PV op, int n, int sz, PV f, int del)
        !            18: {
        !            19:        if (op == 0) return;
        !            20:        if (f) {
        !            21:                register char* p = (char*) op;
        !            22:                for (register int i=0; i<n; i++) PFI(f)(PV(p+i*sz),0);
        !            23:        }
        !            24:        if (del) delete op;
        !            25: }

unix.superglobalmegacorp.com

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