2015-02-17 00:23:33 +01:00
|
|
|
#include <messmer/blockstore/interface/BlockStore.h>
|
|
|
|
#include <messmer/blockstore/utils/BlockStoreUtils.h>
|
2015-01-24 01:24:37 +01:00
|
|
|
#include <memory>
|
2015-02-22 19:29:30 +01:00
|
|
|
#include <cassert>
|
2015-01-24 01:24:37 +01:00
|
|
|
|
|
|
|
using std::unique_ptr;
|
|
|
|
|
|
|
|
namespace blockstore {
|
|
|
|
namespace utils {
|
|
|
|
|
2015-01-24 22:27:14 +01:00
|
|
|
unique_ptr<Block> copyToNewBlock(BlockStore *blockStore, const Block &block) {
|
2015-01-24 01:24:37 +01:00
|
|
|
auto newBlock = blockStore->create(block.size());
|
2015-02-22 19:29:30 +01:00
|
|
|
copyTo(newBlock.get(), block);
|
2015-01-24 01:24:37 +01:00
|
|
|
return newBlock;
|
|
|
|
}
|
|
|
|
|
2015-02-22 19:29:30 +01:00
|
|
|
void copyTo(Block *target, const Block &source) {
|
|
|
|
assert(target->size() == source.size());
|
|
|
|
std::memcpy(target->data(), source.data(), source.size());
|
|
|
|
}
|
|
|
|
|
2015-01-24 01:24:37 +01:00
|
|
|
}
|
|
|
|
}
|