Go to the documentation of this file.
18 #ifndef __LIBALLOC_ALLOCATOR_H
19 #define __LIBALLOC_ALLOCATOR_H
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wnew-returns-null"
207 inline void *
operator new(__SIZE_TYPE__ sz)
211 alloc_args.
size = sz;
215 return (
void *) alloc_args.
address;
217 return (
void *)
NULL;
225 inline void *
operator new[](__SIZE_TYPE__ sz)
229 alloc_args.
size = sz;
233 return (
void *) alloc_args.
address;
235 return (
void *)
NULL;
243 inline void operator delete (
void *mem)
253 inline void operator delete[] (
void *mem)
266 inline void *
operator new(__SIZE_TYPE__ sz,
Address addr)
268 return (
void *) addr;
Allocator * m_parent
Our parent Allocator, if any.
unsigned long Address
A memory address.
Address address
Starting address of the memory range.
Size alignment
Alignment in bytes or ZERO for default alignment.
struct Allocator::Range Range
Describes a range of memory.
virtual ~Allocator()
Class destructor.
Size size
Amount of memory in bytes.
Allocator * parent()
Get parent Allocator.
#define NULL
NULL means zero.
virtual Result allocate(Range &range)
Allocate memory.
unsigned int Size
Any sane size indicator cannot go negative.
virtual Size size() const
Get memory size.
virtual Size available() const
Get memory available.
static Allocator * getDefault()
Retrieve the currently default Allocator.
Address base() const
Get memory base address for allocations.
Size alignment() const
Get memory alignment in bytes for allocations.
Describes a range of memory.
static void setDefault(Allocator *alloc)
Makes the given Allocator the default.
virtual Result release(const Address addr)
Release memory.
Allocator()
Default class constructor.
Range m_range
Range of memory that this Allocator manages.
void setParent(Allocator *parent)
Set parent allocator.
static Allocator * m_default
Points to the default Allocator for new()/delete().
Result
Allocation results.
Address aligned(const Address addr, const Size boundary) const
Align memory address.