FreeNOS
|
Keeps growing allocated memory, and can't actually free memory (hence the name). More...
#include <BubbleAllocator.h>
Public Member Functions | |
BubbleAllocator (const Range range) | |
Class constructor. More... | |
virtual Size | available () const |
Get memory available. More... | |
virtual Result | allocate (Range &args) |
Allocate memory. More... | |
virtual Result | release (const Address addr) |
Release memory. More... | |
Public Member Functions inherited from Allocator | |
Allocator () | |
Default class constructor. More... | |
Allocator (const Range range) | |
Class constructor with Range input. More... | |
virtual | ~Allocator () |
Class destructor. More... | |
void | setParent (Allocator *parent) |
Set parent allocator. More... | |
Allocator * | parent () |
Get parent Allocator. More... | |
Address | base () const |
Get memory base address for allocations. More... | |
Size | alignment () const |
Get memory alignment in bytes for allocations. More... | |
virtual Size | size () const |
Get memory size. More... | |
Private Attributes | |
Size | m_allocated |
Number of bytes allocated. More... | |
Additional Inherited Members | |
Public Types inherited from Allocator | |
enum | Result { Success = 0, InvalidAddress, InvalidSize, InvalidAlignment, OutOfMemory } |
Allocation results. More... | |
typedef struct Allocator::Range | Range |
Describes a range of memory. More... | |
Static Public Member Functions inherited from Allocator | |
static void | setDefault (Allocator *alloc) |
Makes the given Allocator the default. More... | |
static Allocator * | getDefault () |
Retrieve the currently default Allocator. More... | |
Protected Member Functions inherited from Allocator | |
Address | aligned (const Address addr, const Size boundary) const |
Align memory address. More... | |
Keeps growing allocated memory, and can't actually free memory (hence the name).
Definition at line 35 of file BubbleAllocator.h.
BubbleAllocator::BubbleAllocator | ( | const Range | range | ) |
Class constructor.
range | Block of continguous memory to be managed. |
Definition at line 21 of file BubbleAllocator.cpp.
|
virtual |
Allocate memory.
args | Contains the requested size and alignment on input. On output, contains the actual allocated address. |
Reimplemented from Allocator.
Definition at line 32 of file BubbleAllocator.cpp.
References Allocator::Range::address, Allocator::aligned(), Allocator::alignment(), Allocator::base(), m_allocated, Allocator::OutOfMemory, Allocator::Range::size, Allocator::size(), and Allocator::Success.
|
virtual |
Get memory available.
Reimplemented from Allocator.
Definition at line 27 of file BubbleAllocator.cpp.
References m_allocated, and Allocator::size().
|
virtual |
Release memory.
Does nothing for BubbleAllocator.
addr | Points to memory previously returned by allocate(). |
Reimplemented from Allocator.
Definition at line 47 of file BubbleAllocator.cpp.
References Allocator::InvalidAddress.
|
private |
Number of bytes allocated.
Definition at line 80 of file BubbleAllocator.h.
Referenced by allocate(), and available().