18 #ifndef ION_BASE_ALLOCATABLE_H_
19 #define ION_BASE_ALLOCATABLE_H_
21 #include "base/macros.h"
25 #include "ion/external/gtest/gunit_prod.h"
84 void*
operator new(
size_t size) {
return New(size, GetDefaultAllocator()); }
89 return New(size, GetDefaultAllocatorForLifetime(lifetime));
96 return New(size, allocator);
100 void*
operator new(
size_t size,
const AllocatorPtr& allocator,
void* ptr) {
101 return PlacementNew(size, allocator, ptr);
105 void*
operator new(
size_t size,
void* ptr) {
return ptr; }
109 void operator delete(
void* ptr) { Delete(ptr); }
118 void operator delete(
void* ptr,
void* ptr2) {}
152 void*
operator new[](
size_t size);
154 void*
operator new[](
size_t size,
const AllocatorPtr& allocator);
155 void*
operator new[](
size_t size,
void* ptr);
156 void operator delete[](
void* ptr);
158 void operator delete[](
void* ptr,
const AllocatorPtr& allocator);
159 void operator delete[](
void* ptr,
void* ptr2);
168 static const AllocatorPtr& GetDefaultAllocatorForLifetime(
174 static void* New(
size_t size,
const AllocatorPtr& allocator);
175 static void Delete(
void* mem_ptr);
176 static void* PlacementNew(
size_t size,
const AllocatorPtr& allocator,
188 static void SetPlacementAllocator(Allocator* allocator);
192 static Allocator* GetPlacementAllocator();
196 static Helper* GetHelper();
205 const void* memory_ptr_;
208 FRIEND_TEST(AllocatableTest, TrivialType);
214 #endif // ION_BASE_ALLOCATABLE_H_
StlAllocator is derived std::allocator class that allows an Ion Allocator to be used for STL containe...
AllocationLifetime
All memory allocated within Ion uses an Allocator chosen based on the predicted lifetime of the targe...
base::AllocatorPtr allocator_
The Allocator for the FreeTypeManager and all its Fonts.
virtual const AllocatorPtr & GetAllocatorForLifetime(AllocationLifetime lifetime) const
Returns the correct Allocator to use to allocate memory with a specific lifetime. ...
SharedPtr< Allocator > AllocatorPtr
const AllocatorPtr & GetAllocatorForLifetime(AllocationLifetime lifetime) const
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime...
static const AllocatorPtr & GetDefaultAllocator()
Convenience function that returns the default allocator to use when no lifetime is specified...
static const AllocatorPtr & GetNonNullAllocator(const AllocatorPtr &allocator)
This convenience function can be used where a non-NULL Allocator pointer is needed.
Allocatable is an abstract base class for classes whose memory is managed by an Allocator.
Copyright 2016 Google Inc.
const AllocatorPtr & GetNonNullAllocator() const
Return our allocator, or the default allocator if the instance was declared on the stack...
const AllocatorPtr & GetAllocator() const
Returns the Allocator that was used for the instance.
void operator=(const Allocatable &other)
The assignment operator does nothing, since all members are intrinsically tied to a particular alloca...
static const AllocatorPtr & GetDefaultAllocatorForLifetime(AllocationLifetime lifetime)