Class standard_stack_allocator

| Home | Libraries | People | FAQ | More

### Class standard_stack_allocator

Boost.Coroutine provides the class standard_stack_allocator which models the stack-allocator concept. In contrast to protected_stack_allocator it does not append a guard page at the end of each stack. The memory is simply managed by `std::malloc()` and `std::free()`.

| Note
The standard_stack_allocator is the default stack allocator.

    #include <boost/coroutine/standard_stack_allocator.hpp>

    template< typename traitsT >
    struct standard_stack_allocator
    {
        typedef traitT  traits_type;

        void allocate( stack_context &, std::size_t size);

        void deallocate( stack_context &);
    }

    typedef basic_standard_stack_allocator< stack_traits > standard_stack_allocator

##### `void allocate( stack_context & sctx, std::size_t size)`

Preconditions:

  `traits_type::minimum_size() <= size` and `! traits_type::is_unbounded() && ( traits_type::maximum_size() >= size)`.

Effects:

  Allocates memory of at least `size` bytes and stores a pointer to the stack and its actual size in `sctx`. Depending on the architecture (the stack grows downwards/upwards) the stored address is the highest/lowest address of the stack.

##### `void deallocate( stack_context & sctx)`

Preconditions:

  `sctx.sp` is valid, `traits_type::minimum_size() <= sctx.size` and `! traits_type::is_unbounded() && ( traits_type::maximum_size() >= sctx.size)`.

Effects:

  Deallocates the stack space.