Web Analytics Made Easy - Statcounter
Skip to content

Class SBCHeapBook#

ClassList > SBCHeapBook

Public Functions#

Type Name
SBCHeapBook (std::size_t objectSize, unsigned int numberOfObjectsInPage, const std::string & className)
Builds a heap page.
void * allocate ()
Allocates memory for one object.
void free (void * objectPointer)
Frees the memory at address objectPointer.
unsigned long getNumberOfAllocatedObjects () const
Returns the number of allocated objects.
void print (std::ostream & os) const
Prints some debugging information.
void print () const
Prints some debugging information.
virtual ~SBCHeapBook ()
Destroys the heap book and releases all allocated resources.

Public Functions Documentation#

function SBCHeapBook#

Builds a heap page.

SBCHeapBook::SBCHeapBook (
    std::size_t objectSize,
    unsigned int numberOfObjectsInPage,
    const std::string & className
) 

Constructs a heap book for the specified class.

Initializes the heap book and creates the first memory page.

Parameters:

  • objectSize Size of each object in bytes (excluding header).
  • numberOfObjectsInPage Number of objects to allocate per memory page.
  • className Name of the class for which the heap book is created.

function allocate#

Allocates memory for one object.

void * SBCHeapBook::allocate () 

Provides memory for a single object, expanding the heap as necessary.

Returns:

Pointer to the allocated object memory.


function free#

Frees the memory at address objectPointer.

void SBCHeapBook::free (
    void * objectPointer
) 

Frees the memory for the specified object.

Returns the object memory to the heap and updates the free list.

Parameters:

  • objectPointer Pointer to the object memory to be freed.

function getNumberOfAllocatedObjects#

Returns the number of allocated objects.

unsigned long SBCHeapBook::getNumberOfAllocatedObjects () const

Returns the number of currently allocated objects.

Returns:

Number of allocated objects.


function print [1/2]#

Prints some debugging information.

void SBCHeapBook::print (
    std::ostream & os
) const

Prints debugging information to the specified output stream.

Outputs detailed information about each memory page, its cells, and the free list.

Parameters:

  • os Output stream to which the debugging information is printed.

function print [2/2]#

Prints some debugging information.

void SBCHeapBook::print () const

Prints debugging information to the standard output stream.


function ~SBCHeapBook#

Destroys the heap book and releases all allocated resources.

virtual SBCHeapBook::~SBCHeapBook () 

Releases all memory pages and other resources owned by the heap book.