xo-alloc2: bugfix for DX1CollectorIterator
This commit is contained in:
parent
bf27314688
commit
85204e9847
6 changed files with 73 additions and 5 deletions
|
|
@ -4,6 +4,7 @@ set(SELF_LIB xo_alloc2)
|
|||
set(SELF_SRCS
|
||||
|
||||
AllocInfo.cpp
|
||||
cmpresult.cpp
|
||||
|
||||
AAllocator.cpp
|
||||
DArena.cpp
|
||||
|
|
|
|||
|
|
@ -87,6 +87,12 @@ namespace xo {
|
|||
cmpresult
|
||||
DArenaIterator::compare(const DArenaIterator & other_ix) const noexcept
|
||||
{
|
||||
scope log(XO_DEBUG(false),
|
||||
xtag("arena", arena_),
|
||||
xtag("pos", pos_),
|
||||
xtag("other.arena", other_ix.arena_),
|
||||
xtag("other.pos", other_ix.pos_));
|
||||
|
||||
if (is_invalid() || (arena_ != other_ix.arena_))
|
||||
return cmpresult::incomparable();
|
||||
|
||||
|
|
|
|||
|
|
@ -238,11 +238,21 @@ namespace xo {
|
|||
DX1Collector::end() const noexcept {
|
||||
generation gen_hi = generation{config_.n_generation_};
|
||||
|
||||
/** valid iterator for end points to end of last DArena.
|
||||
* otherwise will interfere with working compare
|
||||
* (since invalid iterators are incomparable)
|
||||
**/
|
||||
|
||||
const DArena * arena
|
||||
= get_space(role::to_space(),
|
||||
generation(config_.n_generation_ - 1));
|
||||
DArenaIterator arena_end = arena->end();
|
||||
|
||||
return DX1CollectorIterator(this,
|
||||
gen_hi,
|
||||
gen_hi,
|
||||
DArenaIterator(),
|
||||
DArenaIterator());
|
||||
arena_end,
|
||||
arena_end);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace xo {
|
|||
cmpresult
|
||||
DX1CollectorIterator::compare(const DX1CollectorIterator & other_ix) const noexcept
|
||||
{
|
||||
scope log(XO_DEBUG(true),
|
||||
scope log(XO_DEBUG(false),
|
||||
xtag("is_valid", is_valid()),
|
||||
xtag("other_ix.is_valid", other_ix.is_valid()) );
|
||||
|
||||
|
|
@ -71,7 +71,11 @@ namespace xo {
|
|||
/* both iterators refer to the same arena,
|
||||
* so can compare their arena iterators directly
|
||||
*/
|
||||
return arena_ix_.compare(other_ix.arena_ix_);
|
||||
cmpresult retval = arena_ix_.compare(other_ix.arena_ix_);
|
||||
|
||||
log && log(xtag("retval", retval));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
36
src/alloc2/cmpresult.cpp
Normal file
36
src/alloc2/cmpresult.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/** @file cmpresult.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#include "cmpresult.hpp"
|
||||
#include <xo/indentlog/print/tag.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
const char *
|
||||
comparison2str(comparison x)
|
||||
{
|
||||
switch (x) {
|
||||
case comparison::invalid:
|
||||
return "?comparison";
|
||||
case comparison::comparable:
|
||||
return "cmp";
|
||||
case comparison::incomparable:
|
||||
return "!cmp";
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cmpresult::display(std::ostream & os) const
|
||||
{
|
||||
os << "<cmpresult "
|
||||
<< xtag("err", err_)
|
||||
<< xtag("cmp", cmp_)
|
||||
<< ">";
|
||||
}
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end cmpresult.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue