1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

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

static_cast instead of reinterpret_cast.

llvm-svn: 52686
This commit is contained in:
Dan Gohman 2008-06-24 17:49:26 +00:00
parent 84ca4e44d4
commit 7ee5cc0883

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;
};