Allocator Builder
Policy Based C++ Template Allocator Library
 All Classes Functions Variables Enumerations Enumerator Groups Pages
alb::v_100::aligned_mallocator< DefaultAlignment > Class Template Reference

#include <aligned_mallocator.hpp>

Public Member Functions

block allocate (size_t n) noexcept
 
bool reallocate (block &b, size_t n) noexcept
 
void deallocate (block &b) noexcept
 

Static Public Attributes

static constexpr bool supports_truncated_deallocation = false
 

Detailed Description

template<unsigned DefaultAlignment = 16>
class alb::v_100::aligned_mallocator< DefaultAlignment >

This class implements a proxy to the system ::malloc() with the ALB interface. According the template * parameter DefaultAlignment the allocated values are aligned to the specific boundary in bytes. Normally this should be a multiple of at least 4 bytes.

Template Parameters
DefaultAlignmentSpecified the alignment in bytes of all allocation and reallocations.

Definition at line 27 of file aligned_mallocator.hpp.

Member Function Documentation

template<unsigned DefaultAlignment = 16>
block alb::v_100::aligned_mallocator< DefaultAlignment >::allocate ( size_t  n)
inlinenoexcept

Allocates rounded up to the defined alignment the number of bytes. If the system cannot allocate the specified amount of memory then a null Block is returned.

Definition at line 77 of file aligned_mallocator.hpp.

template<unsigned DefaultAlignment = 16>
void alb::v_100::aligned_mallocator< DefaultAlignment >::deallocate ( block b)
inlinenoexcept

Frees the given block back to the system. The block gets nulled.

Parameters
bThe block, describing what memory shall be freed.

Definition at line 109 of file aligned_mallocator.hpp.

template<unsigned DefaultAlignment = 16>
bool alb::v_100::aligned_mallocator< DefaultAlignment >::reallocate ( block b,
size_t  n 
)
inlinenoexcept

The given block is reallocated to the given size. The new size is aligned to specified alignment. It depends to the OS, if the provided memory block is expanded or moved. It is guaranteed that the values of min(b.length, n) bytes are preserved.

Parameters
bThe block that should be reallocated
nThe new size of the block
Returns
True, if the operation was successful

Definition at line 96 of file aligned_mallocator.hpp.


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