Get rid of some leaks found by VC leak detector.

Patch contributed by Morten Ofsted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18889 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2004-12-13 16:04:04 +00:00
parent 145f8577db
commit 4af3da6e6b
2 changed files with 8 additions and 5 deletions

View File

@ -51,6 +51,7 @@ namespace {
unsigned char *CurStubPtr, *CurFunctionPtr; unsigned char *CurStubPtr, *CurFunctionPtr;
public: public:
JITMemoryManager(); JITMemoryManager();
~JITMemoryManager();
inline unsigned char *allocateStub(unsigned StubSize); inline unsigned char *allocateStub(unsigned StubSize);
inline unsigned char *startFunctionBody(); inline unsigned char *startFunctionBody();
@ -69,6 +70,10 @@ JITMemoryManager::JITMemoryManager() {
CurStubPtr = CurFunctionPtr = FunctionBase; CurStubPtr = CurFunctionPtr = FunctionBase;
} }
JITMemoryManager::~JITMemoryManager() {
sys::Memory::ReleaseRWX(MemBlock);
}
unsigned char *JITMemoryManager::allocateStub(unsigned StubSize) { unsigned char *JITMemoryManager::allocateStub(unsigned StubSize) {
CurStubPtr -= StubSize; CurStubPtr -= StubSize;
if (CurStubPtr < MemBase) { if (CurStubPtr < MemBase) {

View File

@ -33,12 +33,10 @@ namespace llvm { extern std::ostream *GetLibSupportInfoOutputFile(); }
// problem is that a Statistic<> object gets destroyed, which ends up calling // problem is that a Statistic<> object gets destroyed, which ends up calling
// 'GetLibSupportInfoOutputFile()' (below), which calls this function. // 'GetLibSupportInfoOutputFile()' (below), which calls this function.
// LibSupportInfoOutputFilename used to be a global variable, but sometimes it // LibSupportInfoOutputFilename used to be a global variable, but sometimes it
// would get destroyed before the Statistic, causing havoc to ensue. We "fix" // would get destroyed before the Statistic, causing havoc to ensue.
// this by creating the string the first time it is needed and never destroying
// it.
static std::string &getLibSupportInfoOutputFilename() { static std::string &getLibSupportInfoOutputFilename() {
static std::string *LibSupportInfoOutputFilename = new std::string(); static std::string LibSupportInfoOutputFilename;
return *LibSupportInfoOutputFilename; return LibSupportInfoOutputFilename;
} }
namespace { namespace {