mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-27 06:54:30 +00:00
Per code review:\
* Get rid of memory leaks on exception \ * Provide better comments of how the memory handling works llvm-svn: 17876
This commit is contained in:
parent
e816a3abc2
commit
2fe884dad8
@ -377,13 +377,12 @@ bool llvm::GetBytecodeSymbols(const sys::Path& fName,
|
|||||||
std::auto_ptr<ModuleProvider> AMP( getBytecodeModuleProvider(fName.get()));
|
std::auto_ptr<ModuleProvider> AMP( getBytecodeModuleProvider(fName.get()));
|
||||||
|
|
||||||
// Get the module from the provider
|
// Get the module from the provider
|
||||||
Module* M = AMP->releaseModule();
|
Module* M = AMP->materializeModule();
|
||||||
|
|
||||||
// Get the symbols
|
// Get the symbols
|
||||||
getSymbols(M, symbols);
|
getSymbols(M, symbols);
|
||||||
|
|
||||||
// Done with the module
|
// Done with the module
|
||||||
delete M;
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@ -393,12 +392,13 @@ bool llvm::GetBytecodeSymbols(const sys::Path& fName,
|
|||||||
|
|
||||||
ModuleProvider*
|
ModuleProvider*
|
||||||
llvm::GetBytecodeSymbols(const unsigned char*Buffer, unsigned Length,
|
llvm::GetBytecodeSymbols(const unsigned char*Buffer, unsigned Length,
|
||||||
const std::string& ModuleID,
|
const std::string& ModuleID,
|
||||||
std::vector<std::string>& symbols) {
|
std::vector<std::string>& symbols) {
|
||||||
|
|
||||||
|
ModuleProvider* MP = 0;
|
||||||
try {
|
try {
|
||||||
ModuleProvider* MP =
|
// Get the module provider
|
||||||
getBytecodeBufferModuleProvider(Buffer, Length, ModuleID);
|
MP = getBytecodeBufferModuleProvider(Buffer, Length, ModuleID);
|
||||||
|
|
||||||
// Get the module from the provider
|
// Get the module from the provider
|
||||||
Module* M = MP->materializeModule();
|
Module* M = MP->materializeModule();
|
||||||
@ -406,11 +406,15 @@ llvm::GetBytecodeSymbols(const unsigned char*Buffer, unsigned Length,
|
|||||||
// Get the symbols
|
// Get the symbols
|
||||||
getSymbols(M, symbols);
|
getSymbols(M, symbols);
|
||||||
|
|
||||||
// Done with the module
|
// Done with the module. Note that ModuleProvider will delete the
|
||||||
|
// Module when it is deleted. Also note that its the caller's responsibility
|
||||||
|
// to delete the ModuleProvider.
|
||||||
return MP;
|
return MP;
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// Fall through
|
// We only delete the ModuleProvider here because its destructor will
|
||||||
|
// also delete the Module (we used materializeModule not releaseModule).
|
||||||
|
delete MP;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user