summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/StringMap.h
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-04-15 08:59:52 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-04-15 08:59:52 +0000
commit47b284ce3539ef216e0ab994f4b7d762cfb1c69a (patch)
tree6111d2fb0d403c8d94d6889e729b6d509574f0ed /include/llvm/ADT/StringMap.h
parent2727dbcc3766108eca20f48f249aaa87c5a566a2 (diff)
downloadllvm-47b284ce3539ef216e0ab994f4b7d762cfb1c69a.tar.gz
llvm-47b284ce3539ef216e0ab994f4b7d762cfb1c69a.tar.bz2
llvm-47b284ce3539ef216e0ab994f4b7d762cfb1c69a.tar.xz
[Allocator] Pass the size to the deallocation function. This, on some
allocation libraries, may allow more efficient allocation and deallocation. It at least makes the interface implementable by the JIT memory manager. However, this highlights problematic overloading between the void* and the T* deallocation functions. I'm looking into a better way to do this, but as it happens, it comes up rarely in the codebase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206265 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringMap.h')
-rw-r--r--include/llvm/ADT/StringMap.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h
index d4daf53178..f7f940944c 100644
--- a/include/llvm/ADT/StringMap.h
+++ b/include/llvm/ADT/StringMap.h
@@ -198,8 +198,10 @@ public:
template<typename AllocatorTy>
void Destroy(AllocatorTy &Allocator) {
// Free memory referenced by the item.
+ unsigned AllocSize =
+ static_cast<unsigned>(sizeof(StringMapEntry)) + getKeyLength() + 1;
this->~StringMapEntry();
- Allocator.Deallocate(this);
+ Allocator.Deallocate(static_cast<void *>(this), AllocSize);
}
/// Destroy this object, releasing memory back to the malloc allocator.