diff --git a/src/lib/allocation-cluster.hpp b/src/lib/allocation-cluster.hpp index f3a78f3ea..43e0ab920 100644 --- a/src/lib/allocation-cluster.hpp +++ b/src/lib/allocation-cluster.hpp @@ -330,9 +330,37 @@ namespace lib { struct Policy : AllocationPolicy { + using Base = AllocationPolicy; + using Bucket = typename Base::Bucket; + Policy (AllocationCluster& clu) : AllocationPolicy (clu.getAllocator()) { } + + bool + canExpand (Bucket* bucket, size_t request) + { + if (not bucket) return false; + size_t currSize = bucket->getAllocSize(); + size_t delta = request - bucket->buffSiz; + return this->mother_->canAdjust (bucket,currSize, currSize+delta); + } + + Bucket* + realloc (Bucket* bucket, size_t cnt, size_t spread) + { + size_t request = cnt*spread; + REQUIRE (request); + if (not canExpand (bucket,request)) + return Base::realloc (bucket,cnt,spread); + + size_t currSize = bucket->getAllocSize(); + size_t delta = request - bucket->buffSiz; + this->mother_->doAdjust (bucket, currSize, currSize+delta); + bucket->buffSiz += delta; + ENSURE (bucket->buffSiz == request); + return bucket; + } }; }; // diff --git a/src/lib/several-builder.hpp b/src/lib/several-builder.hpp index bb366aaa7..cf818fd40 100644 --- a/src/lib/several-builder.hpp +++ b/src/lib/several-builder.hpp @@ -168,7 +168,7 @@ namespace lib { template class ALO> class ElementFactory - : private ALO + : protected ALO { using Allo = ALO; using AlloT = std::allocator_traits; @@ -261,7 +261,7 @@ namespace lib { ElmAlloT::destroy (elmAllo, elm); } } - size_t storageBytes = bucket->buffOffset + bucket->buffSiz; + size_t storageBytes = bucket->getAllocSize(); std::byte* loc = reinterpret_cast (bucket); AlloT::deallocate (baseAllocator(), loc, storageBytes); }; @@ -277,7 +277,7 @@ namespace lib { using Fac::Fac; // pass-through ctor - bool canExpand(size_t){ return false; } + bool canExpand(Bucket*, size_t){ return false; } Bucket* realloc (Bucket* data, size_t cnt, size_t spread) @@ -510,7 +510,7 @@ namespace lib { { if (not (Coll::empty() or Coll::hasReserve (requiredSiz, newElms) - or POL::canExpand (requiredSiz*newElms) + or POL::canExpand (Coll::data_, requiredSiz*newElms) or canDynGrow())) throw err::Invalid{_Fmt{"Several-container is unable to accommodate further element of type %s; " "storage reserve (%d bytes ≙ %d elms) exhausted and unable to move " diff --git a/src/lib/several.hpp b/src/lib/several.hpp index 2ccdcb1d4..bf882df67 100644 --- a/src/lib/several.hpp +++ b/src/lib/several.hpp @@ -131,6 +131,8 @@ namespace lib { size_t buffOffset; static constexpr size_t storageOffset = sizeof(ArrayBucket); + size_t getAllocSize() const { return buffOffset +buffSiz; } + /** data storage area starts immediately behind the ArrayBucket */ std::byte* @@ -147,6 +149,7 @@ namespace lib { ENSURE (storage() <= elm and elm < storage()+buffSiz); return * std::launder (reinterpret_cast (elm)); } + }; }//(End)implementation details @@ -155,7 +158,7 @@ namespace lib { /************************************************//** * Abstraction: Fixed array of elements. - * Typically the return type is an interface, + * Typically the return type is an interface, * and the Implementation wraps some datastructure * holding subclasses. * @note may only be populated through SeveralBuilder diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 341f2a9fa..df11558d6 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -83688,9 +83688,37 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - - + + + + + + + + + + + +

+ ...ich hab diese Mechanik ganz bewußt janz domm implementiert — also muß praktisch alle Info von oben kommen +

+ + +
+ +
+ + + + + + +
+ + + + + @@ -83703,6 +83731,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + +
@@ -84140,14 +84171,28 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + - - - + + + + + + + + + +

+ ...da AllocationCluster eine starke Größenbeschränkgung hat +

+ + +
+ +