Stan  1.0
probability, sampling & optimization
Public Member Functions | List of all members
stan::memory::chunk_alloc< T, Tnchunks_per_block > Class Template Reference

#include <chunk_alloc.hpp>

Public Member Functions

 chunk_alloc ()
 Construct a resizable chunk allocator initially holding the specified number of bytes. More...
 
 ~chunk_alloc ()
 Destroy this memory allocator. More...
 
void * alloc ()
 Return a newly allocated chunk of memory of the appropriate size managed by the stack allocator. More...
 
void recover_all ()
 Recover all the memory used by the stack allocator. More...
 
void free_all ()
 Free all memory used by the stack allocator other than the initial block allocation back to the system. More...
 

Detailed Description

template<typename T, size_t Tnchunks_per_block = DEFAULT_INITIAL_NCHUNKS>
class stan::memory::chunk_alloc< T, Tnchunks_per_block >

Definition at line 18 of file chunk_alloc.hpp.

Constructor & Destructor Documentation

◆ chunk_alloc()

template<typename T , size_t Tnchunks_per_block = DEFAULT_INITIAL_NCHUNKS>
stan::memory::chunk_alloc< T, Tnchunks_per_block >::chunk_alloc ( )
inline

Construct a resizable chunk allocator initially holding the specified number of bytes.

Exceptions
std::runtime_errorif the underlying malloc is not 8-byte aligned.

Definition at line 33 of file chunk_alloc.hpp.

◆ ~chunk_alloc()

template<typename T , size_t Tnchunks_per_block = DEFAULT_INITIAL_NCHUNKS>
stan::memory::chunk_alloc< T, Tnchunks_per_block >::~chunk_alloc ( )
inline

Destroy this memory allocator.

This is implemented as a no-op as there is no destruction required.

Definition at line 47 of file chunk_alloc.hpp.

Member Function Documentation

◆ alloc()

template<typename T , size_t Tnchunks_per_block = DEFAULT_INITIAL_NCHUNKS>
void* stan::memory::chunk_alloc< T, Tnchunks_per_block >::alloc ( )
inline

Return a newly allocated chunk of memory of the appropriate size managed by the stack allocator.

Returns
A pointer to the allocated memory.

Definition at line 60 of file chunk_alloc.hpp.

◆ free_all()

template<typename T , size_t Tnchunks_per_block = DEFAULT_INITIAL_NCHUNKS>
void stan::memory::chunk_alloc< T, Tnchunks_per_block >::free_all ( )
inline

Free all memory used by the stack allocator other than the initial block allocation back to the system.

Note: the destructor will free all memory.

Definition at line 94 of file chunk_alloc.hpp.

◆ recover_all()

template<typename T , size_t Tnchunks_per_block = DEFAULT_INITIAL_NCHUNKS>
void stan::memory::chunk_alloc< T, Tnchunks_per_block >::recover_all ( )
inline

Recover all the memory used by the stack allocator.

The stack of memory blocks allocated so far will be available for further allocations. To free memory back to the system, use the function free_all().

Definition at line 84 of file chunk_alloc.hpp.


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

     [ Stan Home Page ] © 2011–2012, Stan Development Team.