Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Template simple_stack_allocator< size_t, size_t, size_t >

Boost.Context provides the class simple_stack_allocator which models the StackAllocator concept concept. The template arguments define the limits for the stack size. The class simply allocates memory on the heap via calloc() - in contrast to guarded_stack_allocator no guard page is appended.

[Important] Important

The user is responsible for valid stack limits (e.g. maximum, minimum and default stacksize.

template< size_t Max, size_t Default, size_t Min >
class simple_stack_allocator
{
    static std::size_t maximum_stacksize();

    static std::size_t default_stacksize();

    static std::size_t minimum_stacksize();

    void * allocate( std::size_t size);

    void deallocate( void * sp, std::size_t size);
}
static std::size_t maximum_stacksize()

Returns:

Returns the maximum size in bytes of stack defined by the first tempalte argument.

static std::size_t default_stacksize()

Returns:

Returns a default stack size in bytes defined by the second template argument.

static std::size_t minimum_stacksize()

Returns:

Returns the minimum size in bytes of stack defined by the third template argument.

void * allocate( std::size_t size)

Preconditions:

minimum_stacksize() > size and maximum_stacksize() < size.

Effects:

Allocates memory of size bytes (memory is set to NULL).

Returns:

Returns pointer to the start address of the new stack. Depending on the architecture the stack grows downwards/upwards the returned address is the highest/lowest address of the stack.

void deallocate( void * sp, std::size_t size)

Preconditions:

sp is valid, minimum_stacksize() > size and maximum_stacksize() < size.

Effects:

Deallocates the stack space.


PrevUpHomeNext