henesyinit from p9fce6d0435 years agoHistory
47 lines · 858 B · C
RawDownload
#include "sam.h" /* * Check that list has room for one more element. */voidgrowlist(List *l){	if(l->listptr==0 || l->nalloc==0){		l->nalloc = INCR;		l->listptr = emalloc(INCR*sizeof(long));		l->nused = 0;	}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));		l->nalloc += INCR;	}} /* * Remove the ith element from the list */voiddellist(List *l, int i){	memmove(&l->longptr[i], &l->longptr[i+1], (l->nused-(i+1))*sizeof(long));	l->nused--;} /* * Add a new element, whose position is i, to the list */voidinslist(List *l, int i, long val){	growlist(l);	memmove(&l->longptr[i+1], &l->longptr[i], (l->nused-i)*sizeof(long));	l->longptr[i] = val;	l->nused++;} voidlistfree(List *l){	free(l->listptr);	free(l);}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t