mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.
Once the objects are constructed, they own the buffer. Passing a unique_ptr makes that clear. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211595 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -186,20 +186,19 @@ Archive::Child::getAsBinary(LLVMContext *Context) const {
|
||||
return createBinary(Buff, Context);
|
||||
}
|
||||
|
||||
ErrorOr<Archive*> Archive::create(MemoryBuffer *Source) {
|
||||
ErrorOr<Archive *> Archive::create(std::unique_ptr<MemoryBuffer> Source) {
|
||||
std::error_code EC;
|
||||
std::unique_ptr<Archive> Ret(new Archive(Source, EC));
|
||||
std::unique_ptr<Archive> Ret(new Archive(std::move(Source), EC));
|
||||
if (EC)
|
||||
return EC;
|
||||
return Ret.release();
|
||||
}
|
||||
|
||||
Archive::Archive(MemoryBuffer *source, std::error_code &ec)
|
||||
: Binary(Binary::ID_Archive, source), SymbolTable(child_end()) {
|
||||
Archive::Archive(std::unique_ptr<MemoryBuffer> Source, std::error_code &ec)
|
||||
: Binary(Binary::ID_Archive, std::move(Source)), SymbolTable(child_end()) {
|
||||
// Check for sufficient magic.
|
||||
assert(source);
|
||||
if (source->getBufferSize() < 8 ||
|
||||
StringRef(source->getBufferStart(), 8) != Magic) {
|
||||
if (Data->getBufferSize() < 8 ||
|
||||
StringRef(Data->getBufferStart(), 8) != Magic) {
|
||||
ec = object_error::invalid_file_type;
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user