mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-07 16:54:48 +00:00
Fix for PR2881: fix a small leak exposed by valgrind, using a ManagedStatic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57984 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1cf93952f4
commit
e7d3af5473
@ -12,6 +12,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define DONT_GET_PLUGIN_LOADER_OPTION
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/PluginLoader.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/System/DynamicLibrary.h"
|
||||
@ -19,12 +20,9 @@
|
||||
#include <vector>
|
||||
using namespace llvm;
|
||||
|
||||
static std::vector<std::string> *Plugins;
|
||||
static ManagedStatic<std::vector<std::string> > Plugins;
|
||||
|
||||
void PluginLoader::operator=(const std::string &Filename) {
|
||||
if (!Plugins)
|
||||
Plugins = new std::vector<std::string>();
|
||||
|
||||
std::string Error;
|
||||
if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
|
||||
cerr << "Error opening '" << Filename << "': " << Error
|
||||
@ -35,10 +33,11 @@ void PluginLoader::operator=(const std::string &Filename) {
|
||||
}
|
||||
|
||||
unsigned PluginLoader::getNumPlugins() {
|
||||
return Plugins ? Plugins->size() : 0;
|
||||
return Plugins.isConstructed() ? Plugins->size() : 0;
|
||||
}
|
||||
|
||||
std::string &PluginLoader::getPlugin(unsigned num) {
|
||||
assert(Plugins && num < Plugins->size() && "Asking for an out of bounds plugin");
|
||||
assert(Plugins.isConstructed() && num < Plugins->size() &&
|
||||
"Asking for an out of bounds plugin");
|
||||
return (*Plugins)[num];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user