Skip to content

Commit

Permalink
Merge branch 'fix/leak' into 'develop'
Browse files Browse the repository at this point in the history
Fix/leak

See merge request njoy/scion!3
  • Loading branch information
whaeck committed Oct 15, 2024
2 parents d054304 + 451dab8 commit 2201b60
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
16 changes: 10 additions & 6 deletions src/scion/math/InterpolationTable/src/generateTables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,19 @@ void generateTables() {
}
}

std::swap( xStart, xEnd );
std::swap( yStart, yEnd );
if ( *xStart > *std::prev( xStart ) ) {
// don't do this for the last region: valgrind will yell at you
if ( xEnd != this->x().end() ) {

--xStart;
--yStart;
std::swap( xStart, xEnd );
std::swap( yStart, yEnd );
if ( *xStart > *std::prev( xStart ) ) {

--xStart;
--yStart;
}
}
}

this->linearised_ = linearised;
this->tables_ = tables;
this->tables_ = std::move( tables );
}
14 changes: 10 additions & 4 deletions src/scion/math/InterpolationTable/src/processBoundaries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,17 @@ processBoundaries( std::vector< X >&& x, std::vector< Y >&& y,
throw std::exception();
}
}
if ( *std::next( xIter ) == *xIter ) {

Log::error( "An x value can only be repeated a maximum of two times" );
Log::info( "x = {} is present at least three times", *xIter );
throw std::exception();
// make sure we do not go beyond the end of the x grid: valgrind will yell at you
auto next = std::next( xIter );
if ( next < x.end() ) {

if ( *std::next( xIter ) == *xIter ) {

Log::error( "An x value can only be repeated a maximum of two times" );
Log::info( "x = {} is present at least three times", *xIter );
throw std::exception();
}
}
xIter = std::adjacent_find( xIter, x.end() );
}
Expand Down
16 changes: 10 additions & 6 deletions src/scion/math/InterpolationTableFunction/src/generateTables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ void generateTables() {
}
}

std::swap( xStart, xEnd );
std::swap( fStart, fEnd );
if ( *xStart > *std::prev( xStart ) ) {
// don't do this for the last region: valgrind will yell at you
if ( xEnd != this->x().end() ) {

--xStart;
--fStart;
std::swap( xStart, xEnd );
std::swap( fStart, fEnd );
if ( *xStart > *std::prev( xStart ) ) {

--xStart;
--fStart;
}
}
}

this->tables_ = tables;
this->tables_ = std::move( tables );
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,17 @@ processBoundaries( std::vector< X >&& x, std::vector< F >&& f,
Log::error( "A jump in the x grid cannot occur at the end of the x grid" );
throw std::exception();
}
if ( *std::next( xIter ) == *xIter ) {

Log::error( "An x value can only be repeated a maximum of two times" );
Log::info( "x = {} is present at least three times", *xIter );
throw std::exception();
// make sure we do not go beyond the end of the x grid: valgrind will yell at you
auto next = std::next( xIter );
if ( next < x.end() ) {

if ( *std::next( xIter ) == *xIter ) {

Log::error( "An x value can only be repeated a maximum of two times" );
Log::info( "x = {} is present at least three times", *xIter );
throw std::exception();
}
}
xIter = std::adjacent_find( xIter, x.end() );
}
Expand Down

0 comments on commit 2201b60

Please sign in to comment.