Created
September 1, 2020 17:34
-
-
Save vinniefalco/56e3709db3fde2951a71859cd2a623ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void* | |
static_resource:: | |
do_allocate( | |
std::size_t n, | |
std::size_t align) | |
{ | |
std::size_t const extra = ( | |
align * ((i_ + align - 1) / align)) - i_; | |
if( extra > n_ || | |
n > n_ || | |
n > n_ - extra) | |
BOOST_THROW_EXCEPTION( | |
std::bad_alloc()); | |
void* const p = reinterpret_cast< | |
void*>(i_ + extra); | |
i_+= extra + n; | |
n_ -= extra + n; | |
return p; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment