libcopp  2.2.0
Public Member Functions | Private Attributes
allocator::stack_allocator_memory Class Reference

memory allocator this allocator will return address of specified memory section More...

#include <stack_allocator_memory.h>

Collaboration diagram for allocator::stack_allocator_memory:
Collaboration graph

Public Member Functions

 stack_allocator_memory () LIBCOPP_MACRO_NOEXCEPT
 
 stack_allocator_memory (void *start_ptr, std::size_t max_size) LIBCOPP_MACRO_NOEXCEPT
 
 stack_allocator_memory (stack_allocator_memory &other) LIBCOPP_MACRO_NOEXCEPT
 
 stack_allocator_memory (stack_allocator_memory &&other) LIBCOPP_MACRO_NOEXCEPT
 
 ~stack_allocator_memory ()
 
stack_allocator_memoryoperator= (stack_allocator_memory &other) LIBCOPP_MACRO_NOEXCEPT
 
stack_allocator_memoryoperator= (stack_allocator_memory &&other) LIBCOPP_MACRO_NOEXCEPT
 
void swap (stack_allocator_memory &other)
 
void attach (void *start_ptr, std::size_t max_size) LIBCOPP_MACRO_NOEXCEPT
 
void allocate (stack_context &ctx, std::size_t size) LIBCOPP_MACRO_NOEXCEPT
 
void deallocate (stack_context &ctx) LIBCOPP_MACRO_NOEXCEPT
 

Private Attributes

void * start_ptr_
 
std::size_t memory_size_
 
bool is_used_
 

Detailed Description

memory allocator this allocator will return address of specified memory section

Definition at line 24 of file stack_allocator_memory.h.

Constructor & Destructor Documentation

◆ stack_allocator_memory() [1/4]

LIBCOPP_COPP_API allocator::stack_allocator_memory::stack_allocator_memory ( )

Definition at line 34 of file stack_allocator_memory.cpp.

◆ stack_allocator_memory() [2/4]

LIBCOPP_COPP_API allocator::stack_allocator_memory::stack_allocator_memory ( void *  start_ptr,
std::size_t  max_size 
)

construct and attach to start_ptr with size of max_size

Parameters
start_ptrbuffer start address
max_sizebuffer size

Definition at line 38 of file stack_allocator_memory.cpp.

◆ stack_allocator_memory() [3/4]

LIBCOPP_COPP_API allocator::stack_allocator_memory::stack_allocator_memory ( stack_allocator_memory other)

Definition at line 44 of file stack_allocator_memory.cpp.

References util::swap().

◆ stack_allocator_memory() [4/4]

LIBCOPP_COPP_API allocator::stack_allocator_memory::stack_allocator_memory ( stack_allocator_memory &&  other)

Definition at line 53 of file stack_allocator_memory.cpp.

References util::swap().

◆ ~stack_allocator_memory()

LIBCOPP_COPP_API allocator::stack_allocator_memory::~stack_allocator_memory ( )

Definition at line 62 of file stack_allocator_memory.cpp.

Member Function Documentation

◆ allocate()

LIBCOPP_COPP_API void allocator::stack_allocator_memory::allocate ( stack_context ctx,
std::size_t  size 
)

allocate memory and attach to stack context [standard function]

Parameters
ctxstack context
sizestack size
Note
size must less or equal than attached

Definition at line 93 of file stack_allocator_memory.cpp.

References stack_traits::maximum_size(), stack_traits::minimum_size(), stack_traits::round_to_page_size(), and gsl::size().

◆ attach()

LIBCOPP_COPP_API void allocator::stack_allocator_memory::attach ( void *  start_ptr,
std::size_t  max_size 
)

specify memory section allocated

Parameters
start_ptrbuffer start address
max_sizebuffer size
Note
must be called before allocate operation

Definition at line 87 of file stack_allocator_memory.cpp.

◆ deallocate()

LIBCOPP_COPP_API void allocator::stack_allocator_memory::deallocate ( stack_context ctx)

deallocate memory from stack context [standard function]

Parameters
ctxstack context

Definition at line 115 of file stack_allocator_memory.cpp.

References stack_traits::is_unbounded(), stack_traits::maximum_size(), and stack_traits::minimum_size().

◆ operator=() [1/2]

LIBCOPP_COPP_API stack_allocator_memory & allocator::stack_allocator_memory::operator= ( stack_allocator_memory &&  other)

Definition at line 72 of file stack_allocator_memory.cpp.

References util::swap().

◆ operator=() [2/2]

LIBCOPP_COPP_API stack_allocator_memory & allocator::stack_allocator_memory::operator= ( stack_allocator_memory other)

Definition at line 64 of file stack_allocator_memory.cpp.

References util::swap().

◆ swap()

LIBCOPP_COPP_API void allocator::stack_allocator_memory::swap ( stack_allocator_memory other)

Definition at line 80 of file stack_allocator_memory.cpp.

References is_used_, memory_size_, start_ptr_, and util::swap().

Field Documentation

◆ is_used_

bool allocator::stack_allocator_memory::is_used_
private

Definition at line 28 of file stack_allocator_memory.h.

Referenced by swap().

◆ memory_size_

std::size_t allocator::stack_allocator_memory::memory_size_
private

Definition at line 27 of file stack_allocator_memory.h.

Referenced by swap().

◆ start_ptr_

void* allocator::stack_allocator_memory::start_ptr_
private

Definition at line 26 of file stack_allocator_memory.h.

Referenced by swap().


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