diff --git a/include/Support/MallocAllocator.h b/include/Support/MallocAllocator.h index e063f312ab2..1ba25b0d65e 100644 --- a/include/Support/MallocAllocator.h +++ b/include/Support/MallocAllocator.h @@ -44,11 +44,11 @@ struct MallocAllocator { 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); } @@ -69,4 +69,15 @@ inline bool operator!=(const MallocAllocator&, const MallocAllocator&) { return false; } +namespace std { + template + struct _Alloc_traits > { + static const bool _S_instanceless = true; + typedef ::MallocAllocator base_alloc_type; + typedef ::MallocAllocator _Alloc_type; + typedef ::MallocAllocator allocator_type; + }; +} + + #endif diff --git a/include/llvm/Support/MallocAllocator.h b/include/llvm/Support/MallocAllocator.h index e063f312ab2..1ba25b0d65e 100644 --- a/include/llvm/Support/MallocAllocator.h +++ b/include/llvm/Support/MallocAllocator.h @@ -44,11 +44,11 @@ struct MallocAllocator { 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); } @@ -69,4 +69,15 @@ inline bool operator!=(const MallocAllocator&, const MallocAllocator&) { return false; } +namespace std { + template + struct _Alloc_traits > { + static const bool _S_instanceless = true; + typedef ::MallocAllocator base_alloc_type; + typedef ::MallocAllocator _Alloc_type; + typedef ::MallocAllocator allocator_type; + }; +} + + #endif