summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-12-12 10:27:33 +0000
committerRui Ueyama <ruiu@google.com>2014-12-12 10:27:33 +0000
commit961f43fb70f65a2697f67c6857587608a888e6cb (patch)
tree65cfb4deeb6eed7c6705ebee605de30173cdb968 /lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
parent11a0ac66e10658f9eec87db0e846f6f5eaafc9cf (diff)
downloadbcm5719-llvm-961f43fb70f65a2697f67c6857587608a888e6cb.tar.gz
bcm5719-llvm-961f43fb70f65a2697f67c6857587608a888e6cb.zip
Make File always take the ownership of a MemoryBuffer.
The documentation of parseFile() said that "the resulting File object may take ownership of the MemoryBuffer." So, whether or not the ownership of a MemoryBuffer would be taken was not clear. A FileNode (a subclass of InputElement, which is being deprecated) keeps the ownership if a File doesn't take it. This patch makes File always take the ownership of a buffer. Buffers lifespan is not always the same as File instances. Files are able to deallocate buffers after parsing the contents. llvm-svn: 224113
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp')
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
index 0b3f76c19cb..89c6213c845 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
@@ -520,9 +520,9 @@ public:
}
std::error_code
- parseFile(std::unique_ptr<MemoryBuffer> &mb, const Registry &registry,
+ parseFile(std::unique_ptr<MemoryBuffer> mb, const Registry &registry,
std::vector<std::unique_ptr<File>> &result) const override {
- auto *file = new MachOFile(mb.get(), &_ctx);
+ auto *file = new MachOFile(std::move(mb), &_ctx);
result.push_back(std::unique_ptr<MachOFile>(file));
return std::error_code();
}
@@ -547,9 +547,9 @@ public:
}
std::error_code
- parseFile(std::unique_ptr<MemoryBuffer> &mb, const Registry &registry,
+ parseFile(std::unique_ptr<MemoryBuffer> mb, const Registry &registry,
std::vector<std::unique_ptr<File>> &result) const override {
- auto *file = new MachODylibFile(mb.get(), &_ctx);
+ auto *file = new MachODylibFile(std::move(mb), &_ctx);
result.push_back(std::unique_ptr<MachODylibFile>(file));
return std::error_code();
}
OpenPOWER on IntegriCloud