summaryrefslogtreecommitdiff
path: root/firmware/lru.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/lru.c')
-rw-r--r--firmware/lru.c10
1 files changed, 0 insertions, 10 deletions
diff --git a/firmware/lru.c b/firmware/lru.c
index 798e09fb31..5e1561e492 100644
--- a/firmware/lru.c
+++ b/firmware/lru.c
@@ -48,11 +48,9 @@ void lru_create(struct lru* pl, void *buf, short size, short data_size)
48 for (i=0; i<pl->_size; i++) 48 for (i=0; i<pl->_size; i++)
49 { 49 {
50 lru_node_p(pl, i)->_next = i + 1; 50 lru_node_p(pl, i)->_next = i + 1;
51 lru_node_p(pl, i)->_prev = i - 1;
52 } 51 }
53 52
54 /* Fix up head and tail to form circular buffer */ 53 /* Fix up head and tail to form circular buffer */
55 lru_node_p(pl, 0)->_prev = pl->_tail;
56 lru_node_p(pl, pl->_tail)->_next = pl->_head; 54 lru_node_p(pl, pl->_tail)->_next = pl->_head;
57} 55}
58 56
@@ -92,20 +90,12 @@ void lru_touch(struct lru* pl, short handle)
92 90
93 /* Remove current node from linked list */ 91 /* Remove current node from linked list */
94 struct lru_node* curr_node = lru_node_p(pl, handle); 92 struct lru_node* curr_node = lru_node_p(pl, handle);
95 struct lru_node* prev_node = lru_node_p(pl, curr_node->_prev);
96 struct lru_node* next_node = lru_node_p(pl, curr_node->_next);
97
98 prev_node->_next = curr_node->_next;
99 next_node->_prev = curr_node->_prev;
100 93
101 /* insert current node at tail */ 94 /* insert current node at tail */
102 struct lru_node* tail_node = lru_node_p(pl, pl->_tail); 95 struct lru_node* tail_node = lru_node_p(pl, pl->_tail);
103 short tail_node_next_handle = tail_node->_next; /* Bug fix */ 96 short tail_node_next_handle = tail_node->_next; /* Bug fix */
104 struct lru_node* tail_node_next = lru_node_p(pl, tail_node_next_handle); /* Bug fix */
105 97
106 curr_node->_next = tail_node->_next; 98 curr_node->_next = tail_node->_next;
107 curr_node->_prev = pl->_tail;
108 tail_node_next->_prev = handle; /* Bug fix */
109 tail_node->_next = handle; 99 tail_node->_next = handle;
110 100
111 pl->_tail = handle; 101 pl->_tail = handle;