summaryrefslogtreecommitdiff
path: root/table/block.cc
diff options
context:
space:
mode:
Diffstat (limited to 'table/block.cc')
-rw-r--r--table/block.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/table/block.cc b/table/block.cc
index 40aa318..06eb6f8 100644
--- a/table/block.cc
+++ b/table/block.cc
@@ -19,9 +19,10 @@ inline uint32_t Block::NumRestarts() const {
return DecodeFixed32(data_ + size_ - sizeof(uint32_t));
}
-Block::Block(const char* data, size_t size)
+Block::Block(const char* data, size_t size, bool take_ownership)
: data_(data),
- size_(size) {
+ size_(size),
+ owned_(take_ownership) {
if (size_ < sizeof(uint32_t)) {
size_ = 0; // Error marker
} else {
@@ -35,7 +36,9 @@ Block::Block(const char* data, size_t size)
}
Block::~Block() {
- delete[] data_;
+ if (owned_) {
+ delete[] data_;
+ }
}
// Helper routine: decode the next block entry starting at "p",