Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::DefaultAllocator Class Reference

A simple implementation of Allocator that allocates and frees memory using the new and delete operators and also tracks the number of outstanding allocations. More...

#include <bond/systems/defaultallocator.h>

Inheritance diagram for Bond::DefaultAllocator:
Bond::Allocator

Public Member Functions

 DefaultAllocator ()
 
virtual ~DefaultAllocator ()
 
virtual void * Allocate (size_t size) override
 Allocates and returns a pointer to a block of uninitialized memory of the given size. More...
 
virtual void * AllocateAligned (size_t size, size_t align) override
 Allocates and returns a pointer to a block of uninitialized memory with the given size and alignment. More...
 
virtual void Free (void *buffer) override
 Frees the memory pointed to by the given pointer. The memory must have been allocated by this allocator's Allocate method. More...
 
virtual void FreeAligned (void *buffer) override
 Frees the aligned memory pointed to by the given pointer. The memory must have been allocated by this allocator's Allocate method. More...
 
int GetNumAllocations () const
 Returns the number of outstanding allocations. More...
 
- Public Member Functions inherited from Bond::Allocator
virtual ~Allocator ()
 
virtual void * Allocate (size_t size)=0
 Allocates and returns a pointer to a block of uninitialized memory of the given size. More...
 
virtual void * AllocateAligned (size_t size, size_t align)=0
 Allocates and returns a pointer to a block of uninitialized memory with the given size and alignment. More...
 
virtual void Free (void *buffer)=0
 Frees the memory pointed to by the given pointer. The memory must have been allocated by this allocator's Allocate method. More...
 
virtual void FreeAligned (void *buffer)=0
 Frees the aligned memory pointed to by the given pointer. The memory must have been allocated by this allocator's Allocate method. More...
 
void Free (const void *buffer)
 Calls the non-const form of Free after casting away the constness of the given pointer. More...
 
void FreeAligned (const void *buffer)
 Calls the non-const form of FreeAligned after casting away the constness of the given pointer. More...
 
template<typename T >
T * Alloc ()
 Allocates and returns a pointer to a block of uninitialized memory large enough to accomodate an object of type T. More...
 
template<typename T >
T * Alloc (size_t numElements)
 Allocates and returns a pointer to a block of uninitialized memory large enough to accomodate an array of objects of type T. More...
 
template<typename T >
Handle< T > AllocOwned ()
 Allocates and returns an owning handle to a block of uninitialized memory large enough to accomodate an object of type T. More...
 
template<typename T >
Handle< T > AllocOwned (size_t numElements)
 Allocates and returns an owning handle to a block of uninitialized memory large enough to accomodate an array of objects of type T. More...
 
template<typename T >
T * AllocAligned (size_t align)
 Allocates and returns a pointer to a block of uninitialized aligned memory large enough to accomodate an object of type T. More...
 
template<typename T >
T * AllocAligned (size_t numElements, size_t align)
 Allocates and returns a pointer to a block of uninitialized aligned memory large enough to accomodate an array of objects of type T. More...
 
template<typename T >
AlignedHandle< T > AllocOwnedAligned (size_t align)
 Allocates and returns an owning handle to a block of uninitialized aligned memory large enough to accomodate an object of type T. More...
 
template<typename T >
AlignedHandle< T > AllocOwnedAligned (size_t numElements, size_t align)
 Allocates and returns an owning handle to a block of uninitialized aligned memory large enough to accomodate an array of objects of type T. More...
 
template<typename T , typename... Args>
T * AllocObject (Args &&... args)
 Allocates, constructs and returns a pointer to an instance of type T. More...
 
template<typename T , typename... Args>
ObjectHandle< T > AllocOwnedObject (Args &&... args)
 Allocates, constructs and returns an owning handle to an instance of type T. More...
 
template<typename T , typename... Args>
T * AllocAlignedObject (size_t align, Args &&... args)
 Allocates, constructs and returns a pointer to an aligned instance of type T. More...
 
template<typename T , typename... Args>
AlignedObjectHandle< T > AllocOwnedAlignedObject (size_t align, Args &&... args)
 Allocates, constructs and returns an owning handle to an aligned instance of type T. More...
 

Detailed Description

A simple implementation of Allocator that allocates and frees memory using the new and delete operators and also tracks the number of outstanding allocations.

Constructor & Destructor Documentation

◆ DefaultAllocator()

Bond::DefaultAllocator::DefaultAllocator ( )
inline

◆ ~DefaultAllocator()

virtual Bond::DefaultAllocator::~DefaultAllocator ( )
inlinevirtual

Member Function Documentation

◆ Allocate()

virtual void * Bond::DefaultAllocator::Allocate ( size_t  size)
inlineoverridevirtual

Allocates and returns a pointer to a block of uninitialized memory of the given size.

Implements Bond::Allocator.

◆ AllocateAligned()

virtual void * Bond::DefaultAllocator::AllocateAligned ( size_t  size,
size_t  align 
)
overridevirtual

Allocates and returns a pointer to a block of uninitialized memory with the given size and alignment.

Implements Bond::Allocator.

◆ Free()

virtual void Bond::DefaultAllocator::Free ( void *  buffer)
inlineoverridevirtual

Frees the memory pointed to by the given pointer. The memory must have been allocated by this allocator's Allocate method.

Implements Bond::Allocator.

◆ FreeAligned()

virtual void Bond::DefaultAllocator::FreeAligned ( void *  buffer)
overridevirtual

Frees the aligned memory pointed to by the given pointer. The memory must have been allocated by this allocator's Allocate method.

Implements Bond::Allocator.

◆ GetNumAllocations()

int Bond::DefaultAllocator::GetNumAllocations ( ) const
inline

Returns the number of outstanding allocations.


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