Skip to content

Commit

Permalink
fix(linux/pages): find last page within specified address range
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Jan 9, 2024
1 parent 612b2a4 commit 398e6df
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/page.linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <array>
#include <limits>
#include <ranges>
#include <fstream>
#include <algorithm>
#include <filesystem>
Expand Down Expand Up @@ -171,10 +172,10 @@ namespace lime
{
auto pages = page::pages();

auto it = std::find_if(pages.begin(), pages.end(),
[&](const auto &page) { return address >= page.start() && address <= page.end(); });
auto it = std::ranges::find_if(pages | std::ranges::views::reverse, [&](const auto &page)
{ return address >= page.start() && address <= page.end(); });

if (it == pages.end())
if (it == pages.rend())
{
return std::nullopt;
}
Expand Down

0 comments on commit 398e6df

Please sign in to comment.