Make Allocate<T>() return a T* instead of a void*. And use

static_cast instead of reinterpret_cast.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52686 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2008-06-24 17:49:26 +00:00
parent b70e452820
commit f4dc289cea

View File

@ -25,12 +25,14 @@ public:
~MallocAllocator() {}
void Reset() {}
void *Allocate(size_t Size, size_t Alignment) { return malloc(Size); }
template <typename T>
void *Allocate() { return reinterpret_cast<T*>(malloc(sizeof(T))); }
T *Allocate() { return static_cast<T*>(malloc(sizeof(T))); }
void Deallocate(void *Ptr) { free(Ptr); }
void PrintStats() const {}
};
@ -45,15 +47,16 @@ public:
~BumpPtrAllocator();
void Reset();
void *Allocate(size_t Size, size_t Alignment);
template <typename T>
void *Allocate() {
return reinterpret_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
T *Allocate() {
return static_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
}
void Deallocate(void *Ptr) {}
void PrintStats() const;
};