[llvm-commits] CVS: llvm/include/Support/MallocAllocator.h
Chris Lattner
lattner at cs.uiuc.edu
Fri Nov 7 17:22:01 PST 2003
Changes in directory llvm/include/Support:
MallocAllocator.h updated: 1.2 -> 1.3
---
Log message:
Provide a specialization of _Alloc_traits, which allows the G++ runtime to avoid
storing an instance of the allocator in each data structure it uses. Yaay.
---
Diffs of the changes: (+13 -2)
Index: llvm/include/Support/MallocAllocator.h
diff -u llvm/include/Support/MallocAllocator.h:1.2 llvm/include/Support/MallocAllocator.h:1.3
--- llvm/include/Support/MallocAllocator.h:1.2 Fri Nov 7 09:20:06 2003
+++ llvm/include/Support/MallocAllocator.h Fri Nov 7 17:20:56 2003
@@ -44,11 +44,11 @@
const_pointer address(const_reference x) const { return &x; }
size_type max_size() const { return ~0 / sizeof(T); }
- pointer allocate(size_t n, void* hint = 0) {
+ static pointer allocate(size_t n, void* hint = 0) {
return (pointer)malloc(n*sizeof(T));
}
- void deallocate(pointer p, size_t n) {
+ static void deallocate(pointer p, size_t n) {
free((void*)p);
}
@@ -68,5 +68,16 @@
inline bool operator!=(const MallocAllocator<T>&, const MallocAllocator<T>&) {
return false;
}
+
+namespace std {
+ template<typename Type, typename Type2>
+ struct _Alloc_traits<Type, ::MallocAllocator<Type2> > {
+ static const bool _S_instanceless = true;
+ typedef ::MallocAllocator<Type> base_alloc_type;
+ typedef ::MallocAllocator<Type> _Alloc_type;
+ typedef ::MallocAllocator<Type> allocator_type;
+ };
+}
+
#endif
More information about the llvm-commits
mailing list