summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Bauer <fred.w.bauer@gmail.com>2011-10-22 08:02:38 +0000
committerFred Bauer <fred.w.bauer@gmail.com>2011-10-22 08:02:38 +0000
commite5bdaa3324cbbd6a3e15cf5af569f74f1963f392 (patch)
treefcdc1fd52156f50f07626241f527de8b233bb67a
parent9c75ec0f9a473f77b02fcfa45d7da350fcb02c9a (diff)
downloadrockbox-e5bdaa3324cbbd6a3e15cf5af569f74f1963f392.tar.gz
rockbox-e5bdaa3324cbbd6a3e15cf5af569f74f1963f392.zip
Revert r30818
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30821 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/lru.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/firmware/lru.c b/firmware/lru.c
index c2e296f03c..798e09fb31 100644
--- a/firmware/lru.c
+++ b/firmware/lru.c
@@ -23,6 +23,7 @@
23struct lru_node 23struct lru_node
24{ 24{
25 short _next; 25 short _next;
26 short _prev;
26 unsigned char data[1]; /* place holder */ 27 unsigned char data[1]; /* place holder */
27}; 28};
28 29
@@ -47,9 +48,11 @@ void lru_create(struct lru* pl, void *buf, short size, short data_size)
47 for (i=0; i<pl->_size; i++) 48 for (i=0; i<pl->_size; i++)
48 { 49 {
49 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;
50 } 52 }
51 53
52 /* Fix up head and tail to form circular buffer */ 54 /* Fix up head and tail to form circular buffer */
55 lru_node_p(pl, 0)->_prev = pl->_tail;
53 lru_node_p(pl, pl->_tail)->_next = pl->_head; 56 lru_node_p(pl, pl->_tail)->_next = pl->_head;
54} 57}
55 58
@@ -89,11 +92,20 @@ void lru_touch(struct lru* pl, short handle)
89 92
90 /* Remove current node from linked list */ 93 /* Remove current node from linked list */
91 struct lru_node* curr_node = lru_node_p(pl, handle); 94 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;
92 100
93 /* insert current node at tail */ 101 /* insert current node at tail */
94 struct lru_node* tail_node = lru_node_p(pl, pl->_tail); 102 struct lru_node* tail_node = lru_node_p(pl, pl->_tail);
103 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 */
95 105
96 curr_node->_next = tail_node->_next; 106 curr_node->_next = tail_node->_next;
107 curr_node->_prev = pl->_tail;
108 tail_node_next->_prev = handle; /* Bug fix */
97 tail_node->_next = handle; 109 tail_node->_next = handle;
98 110
99 pl->_tail = handle; 111 pl->_tail = handle;