OSDN Git Service

Get rid of some leaks found by VC leak detector.
authorReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 16:04:04 +0000 (16:04 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 16:04:04 +0000 (16:04 +0000)
Patch contributed by Morten Ofsted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18889 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JIT/JITEmitter.cpp
lib/Support/Timer.cpp

index eff24de..6603433 100644 (file)
@@ -51,6 +51,7 @@ namespace {
     unsigned char *CurStubPtr, *CurFunctionPtr;
   public:
     JITMemoryManager();
+    ~JITMemoryManager();
     
     inline unsigned char *allocateStub(unsigned StubSize);
     inline unsigned char *startFunctionBody();
@@ -69,6 +70,10 @@ JITMemoryManager::JITMemoryManager() {
   CurStubPtr = CurFunctionPtr = FunctionBase;
 }
 
+JITMemoryManager::~JITMemoryManager() {
+  sys::Memory::ReleaseRWX(MemBlock);
+}
+
 unsigned char *JITMemoryManager::allocateStub(unsigned StubSize) {
   CurStubPtr -= StubSize;
   if (CurStubPtr < MemBase) {
index ff3fd6f..4b88be2 100644 (file)
@@ -33,12 +33,10 @@ namespace llvm { extern std::ostream *GetLibSupportInfoOutputFile(); }
 // problem is that a Statistic<> object gets destroyed, which ends up calling
 // 'GetLibSupportInfoOutputFile()' (below), which calls this function.
 // LibSupportInfoOutputFilename used to be a global variable, but sometimes it
-// would get destroyed before the Statistic, causing havoc to ensue.  We "fix"
-// this by creating the string the first time it is needed and never destroying
-// it.
+// would get destroyed before the Statistic, causing havoc to ensue.
 static std::string &getLibSupportInfoOutputFilename() {
-  static std::string *LibSupportInfoOutputFilename = new std::string();
-  return *LibSupportInfoOutputFilename;
+  static std::string LibSupportInfoOutputFilename;
+  return LibSupportInfoOutputFilename;
 }
 
 namespace {