4 * Check that list has room for one more element.
7 growlist(List *l, int esize)
11 if(l->listptr == nil || l->nalloc == 0){
13 l->listptr = emalloc(INCR*esize);
16 else if(l->nused == l->nalloc){
17 p = erealloc(l->listptr, (l->nalloc+INCR)*esize);
19 memset(p+l->nalloc*esize, 0, INCR*esize);
25 * Remove the ith element from the list
28 dellist(List *l, int i)
38 memmove(pp, pp+1, (l->nused-i)*sizeof(*pp));
42 memmove(vpp, vpp+1, (l->nused-i)*sizeof(*vpp));
48 * Add a new element, whose position is i, to the list
51 inslist(List *l, int i, ...)
61 growlist(l, sizeof(*pp));
63 memmove(pp+1, pp, (l->nused-i)*sizeof(*pp));
64 *pp = va_arg(list, Posn);
67 growlist(l, sizeof(*vpp));
69 memmove(vpp+1, vpp, (l->nused-i)*sizeof(*vpp));
70 *vpp = va_arg(list, void*);
90 l = emalloc(sizeof(List));