From 1614284eff49f28c5320dba6905e8d66f760f096 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Wed, 16 Jul 2014 06:45:49 -0700 Subject: [PATCH] Fix compressed cache --- table/block_based_table_builder.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/table/block_based_table_builder.cc b/table/block_based_table_builder.cc index ae27734c9..fdaa9d341 100644 --- a/table/block_based_table_builder.cc +++ b/table/block_based_table_builder.cc @@ -612,8 +612,8 @@ static void DeleteCachedBlock(const Slice& key, void* value) { // Make a copy of the block contents and insert into compressed block cache // Status BlockBasedTableBuilder::InsertBlockInCache(const Slice& block_contents, - const CompressionType type, - const BlockHandle* handle) { + const CompressionType type, + const BlockHandle* handle) { Rep* r = rep_; Cache* block_cache_compressed = r->options.block_cache_compressed.get(); @@ -622,8 +622,9 @@ Status BlockBasedTableBuilder::InsertBlockInCache(const Slice& block_contents, Cache::Handle* cache_handle = nullptr; size_t size = block_contents.size(); - char* ubuf = new char[size]; // make a new copy + char* ubuf = new char[size + 1]; // make a new copy memcpy(ubuf, block_contents.data(), size); + ubuf[size] = type; BlockContents results; Slice sl(ubuf, size);