[llvm] r216361 - EE/JIT: unique_ptr-ify

Dylan Noblesmith nobled at dreamwidth.org
Sun Aug 24 17:58:16 PDT 2014


Author: nobled
Date: Sun Aug 24 19:58:15 2014
New Revision: 216361

URL: http://llvm.org/viewvc/llvm-project?rev=216361&view=rev
Log:
EE/JIT: unique_ptr-ify

Modified:
    llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp?rev=216361&r1=216360&r2=216361&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp Sun Aug 24 19:58:15 2014
@@ -324,7 +324,7 @@ namespace {
     // When emitting code into a memory block, this is the block.
     MemoryRangeHeader *CurBlock;
 
-    uint8_t *GOTBase;     // Target Specific reserved memory
+    std::unique_ptr<uint8_t[]> GOTBase; // Target Specific reserved memory
   public:
     DefaultJITMemoryManager();
     ~DefaultJITMemoryManager();
@@ -525,7 +525,7 @@ namespace {
     }
 
     uint8_t *getGOTBase() const override {
-      return GOTBase;
+      return GOTBase.get();
     }
 
     void deallocateBlock(void *Block) {
@@ -638,21 +638,17 @@ DefaultJITMemoryManager::DefaultJITMemor
 
   // Start out with the freelist pointing to Mem0.
   FreeMemoryList = Mem0;
-
-  GOTBase = nullptr;
 }
 
 void DefaultJITMemoryManager::AllocateGOT() {
   assert(!GOTBase && "Cannot allocate the got multiple times");
-  GOTBase = new uint8_t[sizeof(void*) * 8192];
+  GOTBase = make_unique<uint8_t[]>(sizeof(void*) * 8192);
   HasGOT = true;
 }
 
 DefaultJITMemoryManager::~DefaultJITMemoryManager() {
   for (unsigned i = 0, e = CodeSlabs.size(); i != e; ++i)
     sys::Memory::ReleaseRWX(CodeSlabs[i]);
-
-  delete[] GOTBase;
 }
 
 sys::MemoryBlock DefaultJITMemoryManager::allocateNewSlab(size_t size) {





More information about the llvm-commits mailing list