rminnichinitial1fcdf7916 years agoHistory
75 lines · 1013 B · C
RawDownload
/* *  lru lists are circular with a list head *  pointing to the start and end of the list */#include <u.h>#include "lru.h" /* *  Create an lru chain of buffers */voidlruinit(Lru *h){	h->lprev = h->lnext = h;} /* *  Add a member to an lru chain */voidlruadd(Lru *h, Lru *m){	h->lprev->lnext = m;	m->lprev = h->lprev;	h->lprev = m;	m->lnext = h;} /* *  Move to end of lru list */voidlruref(Lru *h, Lru *m){	if(h->lprev == m)		return;		/* alread at end of list */ 	/*	 *  remove from list	 */	m->lprev->lnext = m->lnext;	m->lnext->lprev = m->lprev; 	/*	 *  add in at end	 */	h->lprev->lnext = m;	m->lprev = h->lprev;	h->lprev = m;	m->lnext = h;} /* *  Move to head of lru list */voidlruderef(Lru *h, Lru *m){	if(h->lnext == m)		return;		/* alread at head of list */ 	/*	 *  remove from list	 */	m->lprev->lnext = m->lnext;	m->lnext->lprev = m->lprev; 	/*	 *  add in at head	 */	h->lnext->lprev = m;	m->lnext = h->lnext;	h->lnext = m;	m->lprev = h;}

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