mohaps / lrucache11

A header only C++11 LRU Cache template class that allows you to define key, value and optionally the Map type. uses a double linked list and a std::unordered_map style container to provide fast insert, delete and update No dependencies other than the C++ standard library. This is a C++11 remake of my earlier LRUCache project (https://github.com/mohaps/lrucache) The goal was to create a fast LRUCache header only library and to avoid any dependencies like boost.
https://github.com/mohaps/lrucache11
294 stars 63 forks source link

Set prev link properly when adding to a 1-item list. #4

Closed danpat closed 8 years ago

danpat commented 8 years ago

When there is only 1 item in the list, a newly appended n node didn't have the prev property set correctly. This leads to segfaults when calling get on the second item, because we later try to de-reference a nullptr that should be pointing to head.