Annotation of researchv9/jtools/src/sam/list.c, revision 1.1.1.1

1.1       root        1: #include "sam.h"
                      2: 
                      3: /*
                      4:  * Check that list has room for one more element.
                      5:  */
                      6: growlist(l)
                      7:        register List *l;
                      8: {
                      9:        if(l->ptr==0 || l->nalloc==0){
                     10:                gcnew(l->ptr, l->nalloc=INCR);
                     11:                l->nused=0;
                     12:        }else if(l->nused==l->nalloc)
                     13:                gcrenew(l->ptr, l->nalloc+=INCR);
                     14: }
                     15: /*
                     16:  * Remove the ith element from the list
                     17:  */
                     18: dellist(l, i)
                     19:        register List *l;
                     20: {
                     21:        bcopy((uchar *)&l->ptr[i+1], (uchar *)&l->ptr[l->nused],
                     22:                (uchar *)&l->ptr[i], 1);
                     23:        l->nused--;
                     24: }
                     25: /*
                     26:  * Add a new element, whose position is i, to the list
                     27:  */
                     28: inslist(l, i, val)
                     29:        register List *l;
                     30:        register i;
                     31:        long val;
                     32: {
                     33:        growlist(l);
                     34:        bcopy((uchar *)&l->ptr[i], (uchar *)&l->ptr[l->nused],
                     35:                (uchar *)&l->ptr[i+1], -1);
                     36:        l->ptr[i]=val;
                     37:        l->nused++;
                     38: }
                     39: listfree(l)
                     40:        register List *l;
                     41: {
                     42:        gcfree((uchar *)l->ptr);
                     43:        free((uchar *)l);
                     44: }

unix.superglobalmegacorp.com

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