CACAO
Public Member Functions | Private Attributes | Static Private Attributes
DumpMemoryBlock Class Reference

Dump memory block. More...

Public Member Functions

 DumpMemoryBlock (size_t size=0)
 Checks canaries in this dump memory area. More...
 
 ~DumpMemoryBlock ()
 Release the memory block for the dump memory block. More...
 
size_t get_size () const
 
size_t get_used () const
 
size_t get_free () const
 
voidallocate (size_t size)
 Allocate memory in the current dump memory area. More...
 

Private Attributes

size_t _size
 Size of the current memory block. More...
 
size_t _used
 Used memory in the current memory block. More...
 
void_block
 List of memory blocks in this area. More...
 

Static Private Attributes

static const size_t DEFAULT_SIZE = 2 << 13
 

Detailed Description

Dump memory block.

Definition at line 122 of file dumpmemory.hpp.

Constructor & Destructor Documentation

DumpMemoryBlock::DumpMemoryBlock ( size_t  size = 0)

Checks canaries in this dump memory area.

If any canary has been changed, this function aborts the VM with an error message. Allocate a memory block for the current dump memory block.

Parameters
sizeRequired memory size.

Definition at line 242 of file dumpmemory.cpp.

DumpMemoryBlock::~DumpMemoryBlock ( )

Release the memory block for the dump memory block.

Parameters
sizeRequired memory size.

Definition at line 262 of file dumpmemory.cpp.

Member Function Documentation

void * DumpMemoryBlock::allocate ( size_t  size)
inline

Allocate memory in the current dump memory area.

This function is a fast allocator suitable for scratch memory that can be collectively freed when the current activity (eg. compiling) is done.

You cannot selectively free dump memory. Before you start allocating it, you remember the current size returned by dumpmemory_marker. Later, when you no longer need the memory, call dumpmemory_release with the remembered size and all dump memory allocated since the call to dumpmemory_marker will be freed.

size Size of block to allocate in bytes. May be zero, in which case NULL is returned

Returns
Pointer to allocated memory, or NULL iff size was zero.

Definition at line 351 of file dumpmemory.hpp.

size_t DumpMemoryBlock::get_free ( ) const
inline

Definition at line 136 of file dumpmemory.hpp.

size_t DumpMemoryBlock::get_size ( ) const
inline

Definition at line 134 of file dumpmemory.hpp.

size_t DumpMemoryBlock::get_used ( ) const
inline

Definition at line 135 of file dumpmemory.hpp.

Field Documentation

void* DumpMemoryBlock::_block
private

List of memory blocks in this area.

Definition at line 128 of file dumpmemory.hpp.

size_t DumpMemoryBlock::_size
private

Size of the current memory block.

Definition at line 126 of file dumpmemory.hpp.

size_t DumpMemoryBlock::_used
private

Used memory in the current memory block.

Definition at line 127 of file dumpmemory.hpp.

const size_t DumpMemoryBlock::DEFAULT_SIZE = 2 << 13
staticprivate

Definition at line 124 of file dumpmemory.hpp.


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