Class 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:
objectSizeSize of each object in bytes (excluding header).numberOfObjectsInPageNumber of objects to allocate per memory page.classNameName of the class for which the heap book is created.
function allocate#
Allocates memory for one object.
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.
Frees the memory for the specified object.
Returns the object memory to the heap and updates the free list.
Parameters:
objectPointerPointer to the object memory to be freed.
function getNumberOfAllocatedObjects#
Returns the number of allocated objects.
Returns the number of currently allocated objects.
Returns:
Number of allocated objects.
function print [1/2]#
Prints some debugging information.
Prints debugging information to the specified output stream.
Outputs detailed information about each memory page, its cells, and the free list.
Parameters:
osOutput stream to which the debugging information is printed.
function print [2/2]#
Prints some debugging information.
Prints debugging information to the standard output stream.
function ~SBCHeapBook#
Destroys the heap book and releases all allocated resources.
Releases all memory pages and other resources owned by the heap book.