EE/JIT: unique_ptr-ify
authorDylan Noblesmith <nobled@dreamwidth.org>
Mon, 25 Aug 2014 00:58:15 +0000 (00:58 +0000)
committerDylan Noblesmith <nobled@dreamwidth.org>
Mon, 25 Aug 2014 00:58:15 +0000 (00:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216361 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JIT/JITMemoryManager.cpp

index 584b93f81502a367012540f8eef2d366c8d9960e..0741f6ad94e63a7784efe2dd2216960486b01e10 100644 (file)
@@ -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::DefaultJITMemoryManager()
 
   // 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) {