mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
Added member template functions to MallocAllocator and
BumpPtrAllocator that implement allocations that return a properly typed pointer. For BumpPtrAllocator, the allocated memory is automatically aligned to the minimum alignment of the type (as calculated by llvm::AlignOf::Alignment). llvm-svn: 43087
This commit is contained in:
parent
d82172cc2c
commit
9008297075
@ -14,6 +14,7 @@
|
||||
#ifndef LLVM_SUPPORT_ALLOCATOR_H
|
||||
#define LLVM_SUPPORT_ALLOCATOR_H
|
||||
|
||||
#include "llvm/Support/AlignOf.h"
|
||||
#include <cstdlib>
|
||||
|
||||
namespace llvm {
|
||||
@ -25,6 +26,10 @@ public:
|
||||
|
||||
void Reset() {}
|
||||
void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
|
||||
|
||||
template <typename T>
|
||||
T* Allocate() { return reinterpret_cast<T*>(malloc(sizeof(T))); }
|
||||
|
||||
void Deallocate(void *Ptr) { free(Ptr); }
|
||||
void PrintStats() const {}
|
||||
};
|
||||
@ -41,6 +46,13 @@ public:
|
||||
|
||||
void Reset();
|
||||
void *Allocate(unsigned Size, unsigned Alignment);
|
||||
|
||||
template <typename T>
|
||||
T* Allocate() {
|
||||
return reinterpret_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
|
||||
}
|
||||
|
||||
|
||||
void Deallocate(void *Ptr) {}
|
||||
void PrintStats() const;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user