mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9795 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -44,11 +44,11 @@ struct MallocAllocator {
|
|||||||
const_pointer address(const_reference x) const { return &x; }
|
const_pointer address(const_reference x) const { return &x; }
|
||||||
size_type max_size() const { return ~0 / sizeof(T); }
|
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));
|
return (pointer)malloc(n*sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate(pointer p, size_t n) {
|
static void deallocate(pointer p, size_t n) {
|
||||||
free((void*)p);
|
free((void*)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,4 +69,15 @@ inline bool operator!=(const MallocAllocator<T>&, const MallocAllocator<T>&) {
|
|||||||
return false;
|
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
|
#endif
|
||||||
|
@ -44,11 +44,11 @@ struct MallocAllocator {
|
|||||||
const_pointer address(const_reference x) const { return &x; }
|
const_pointer address(const_reference x) const { return &x; }
|
||||||
size_type max_size() const { return ~0 / sizeof(T); }
|
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));
|
return (pointer)malloc(n*sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate(pointer p, size_t n) {
|
static void deallocate(pointer p, size_t n) {
|
||||||
free((void*)p);
|
free((void*)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,4 +69,15 @@ inline bool operator!=(const MallocAllocator<T>&, const MallocAllocator<T>&) {
|
|||||||
return false;
|
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
|
#endif
|
||||||
|
Reference in New Issue
Block a user