FreeNOS
Public Member Functions | Private Attributes
BubbleAllocator Class Reference

Keeps growing allocated memory, and can't actually free memory (hence the name). More...

#include <BubbleAllocator.h>

Inheritance diagram for BubbleAllocator:
Allocator

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...
 
Allocatorparent ()
 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 AllocatorgetDefault ()
 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...
 

Detailed Description

Keeps growing allocated memory, and can't actually free memory (hence the name).

Definition at line 35 of file BubbleAllocator.h.

Constructor & Destructor Documentation

◆ BubbleAllocator()

BubbleAllocator::BubbleAllocator ( const Range  range)

Class constructor.

Parameters
rangeBlock of continguous memory to be managed.

Definition at line 21 of file BubbleAllocator.cpp.

Member Function Documentation

◆ allocate()

Allocator::Result BubbleAllocator::allocate ( Allocator::Range args)
virtual

Allocate memory.

Parameters
argsContains the requested size and alignment on input. On output, contains the actual allocated address.
Returns
Result value.
Note
The alignment field in args is ignored. Only the alignment value passed to the constructor is used.

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.

◆ available()

Size BubbleAllocator::available ( ) const
virtual

Get memory available.

Returns
Size of memory available by the Allocator.

Reimplemented from Allocator.

Definition at line 27 of file BubbleAllocator.cpp.

References m_allocated, and Allocator::size().

◆ release()

Allocator::Result BubbleAllocator::release ( const Address  addr)
virtual

Release memory.

Does nothing for BubbleAllocator.

Parameters
addrPoints to memory previously returned by allocate().
See also
allocate

Reimplemented from Allocator.

Definition at line 47 of file BubbleAllocator.cpp.

References Allocator::InvalidAddress.

Field Documentation

◆ m_allocated

Size BubbleAllocator::m_allocated
private

Number of bytes allocated.

Definition at line 80 of file BubbleAllocator.h.

Referenced by allocate(), and available().


The documentation for this class was generated from the following files: