1
0
forked from Alepha/Alepha

Start moving towards the alignment solution>

Some of this needs to be branched out.
This commit is contained in:
2024-05-20 19:00:37 -04:00
parent 7577caf47b
commit ff738b9301
3 changed files with 13 additions and 7 deletions

View File

@ -58,15 +58,15 @@ namespace Alepha::Hydrogen::Memory ::detail:: ThreadSlab_m
{
// TODO: Alignment?
const std::size_t req= amt + sizeof( Blob::StorageReservation );
if( req > C::slabSize ) throw std::bad_alloc{}; //{ "Unable to allocate larger than the slab size." };
if( slab.size() < req ) slab.reset( std::max( req, C::slabSize ) );
std::cerr << "Reporting " << slab.reservation().use_count() << " living allocations when "
<< (void *) this << " made an allocation." << std::endl;
auto next= slab.carveHead( req );
new ( &next.template as< Blob::StorageReservation >() ) Blob::StorageReservation{ next.reservation() };
auto next= slab.carveHead( req, Alignment{ sizeof( Blob::StorageReservation ) } );
const auto rv= reinterpret_cast< T * >( &next.template as< Blob::StorageReservation >() + 1 );
next.reset();
new ( &next.template as< Blob::StorageReservation >() ) Blob::StorageReservation{ std::move( next.reservation() ) };
std::cerr << "Reporting " << slab.reservation().use_count() << " living allocations when "
<< (void *) this << " made an allocation." << std::endl;