Skip to content

Commit

Permalink
refactor(page): use MAP_FAILED macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Jul 11, 2023
1 parent a4743c2 commit ec62e6a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/page.linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ namespace lime
const auto prot = impl::translate(protection);
auto *alloc = mmap(addr, size, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

if (alloc == reinterpret_cast<void *>(-1))
if (alloc == MAP_FAILED)
{
return nullptr;
}
Expand All @@ -206,12 +206,12 @@ namespace lime
protection protection)
{
auto aligned = where & (getpagesize() - 1) ? (where + getpagesize()) & ~(getpagesize() - 1) : where;
auto *alloc = reinterpret_cast<void *>(-1);
auto *alloc = MAP_FAILED;

const auto flags = MAP_PRIVATE | MAP_ANON | MAP_FIXED_NOREPLACE;
const auto prot = impl::translate(protection);

while (alloc == reinterpret_cast<void *>(-1))
while (alloc == MAP_FAILED)
{
const auto diff = aligned - where;

Expand Down

0 comments on commit ec62e6a

Please sign in to comment.