diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/font_cache.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/firmware/font_cache.c b/firmware/font_cache.c index 34a14e0551..f816635161 100644 --- a/firmware/font_cache.c +++ b/firmware/font_cache.c | |||
@@ -181,31 +181,20 @@ struct font_cache_entry* font_cache_get( | |||
181 | 181 | ||
182 | if (insertion_point < index_to_replace) | 182 | if (insertion_point < index_to_replace) |
183 | { | 183 | { |
184 | /* shift memory down */ | 184 | /* shift memory up */ |
185 | int dest = insertion_point+2; | 185 | memmove(fcache->_index + insertion_point + 2, |
186 | int src = insertion_point+1; | 186 | fcache->_index + insertion_point + 1, |
187 | int len = index_to_replace - insertion_point - 1; | 187 | (index_to_replace - insertion_point - 1) * sizeof(short)); |
188 | |||
189 | int desti = dest + len - 1; | ||
190 | int srci = src + len - 1; | ||
191 | |||
192 | int i; | ||
193 | for (i = 0; i < len; i++) | ||
194 | fcache->_index[desti--] = fcache->_index[srci--]; | ||
195 | 188 | ||
196 | /* add to index */ | 189 | /* add to index */ |
197 | fcache->_index[insertion_point + 1] = lru_handle_to_replace; | 190 | fcache->_index[insertion_point + 1] = lru_handle_to_replace; |
198 | } | 191 | } |
199 | else if (insertion_point > index_to_replace) | 192 | else if (insertion_point > index_to_replace) |
200 | { | 193 | { |
201 | /* shift memory up */ | 194 | /* shift memory down */ |
202 | int dest = index_to_replace; | 195 | memmove(fcache->_index + index_to_replace, |
203 | int src = index_to_replace + 1; | 196 | fcache->_index + index_to_replace + 1, |
204 | int len = insertion_point - index_to_replace; | 197 | (insertion_point - index_to_replace) * sizeof(short)); |
205 | |||
206 | int i; | ||
207 | for (i=0; i < len; i++) | ||
208 | fcache->_index[dest++] = fcache->_index[src++]; | ||
209 | 198 | ||
210 | /* add to index */ | 199 | /* add to index */ |
211 | fcache->_index[insertion_point] = lru_handle_to_replace; | 200 | fcache->_index[insertion_point] = lru_handle_to_replace; |