| * Check that list has room for one more element. |
| if(l->listptr==0 || l->nalloc==0){ |
| l->listptr = emalloc(INCR*sizeof(long)); |
| }else if(l->nused == l->nalloc){ |
| l->listptr = erealloc(l->listptr, (l->nalloc+INCR)*sizeof(long)); |
| memset((void*)(l->longptr+l->nalloc), 0, INCR*sizeof(long)); |
| * Remove the ith element from the list |
| memmove(&l->longptr[i], &l->longptr[i+1], (l->nused-(i+1))*sizeof(long)); |
| * Add a new element, whose position is i, to the list |
| inslist(List *l, int i, long val) |
| memmove(&l->longptr[i+1], &l->longptr[i], (l->nused-i)*sizeof(long)); |