From 3a98a7ae7fb16f1c1d85ca6da4ca8b27e4866398 Mon Sep 17 00:00:00 2001 From: SherlockNoMad Date: Fri, 4 Dec 2015 15:12:07 -0800 Subject: [PATCH] Replace malloc with new for LRU Cache Handle --- util/cache.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/cache.cc b/util/cache.cc index e64c01e7b..9c47edd0e 100644 --- a/util/cache.cc +++ b/util/cache.cc @@ -74,7 +74,7 @@ struct LRUHandle { void Free() { assert((refs == 1 && in_cache) || (refs == 0 && !in_cache)); (*deleter)(key(), value); - free(this); + delete[] reinterpret_cast(this); } }; @@ -390,8 +390,8 @@ Cache::Handle* LRUCache::Insert( // Allocate the memory here outside of the mutex // If the cache is full, we'll have to release it // It shouldn't happen very often though. - LRUHandle* e = - reinterpret_cast(malloc(sizeof(LRUHandle) - 1 + key.size())); + LRUHandle* e = reinterpret_cast( + new char[sizeof(LRUHandle) - 1 + key.size()]); autovector last_reference_list; e->value = value;