Skip to content

Commit

Permalink
Get rid of std::sort
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Nov 29, 2022
1 parent 7428a76 commit f652f0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ const std::vector<MemRegion> &ProcessRuntimeUtility::GetProcessMemoryLayout() {
MemRegion region = MemRegion(region_start,region_end - region_start, permission);
regions.push_back(region);
}
std::sort(regions.begin(), regions.end(), memory_region_comparator);
std::qsort(&regions[0], regions.size(), sizeof(MemRegion),
+[](const void* a, const void* b) -> int {
const auto *i = static_cast<const MemRegion *>(a);
const auto *j = static_cast<const MemRegion *>(b);
if ((addr_t)i->start < (addr_t)j->start) return -1;
if ((addr_t)i->start > (addr_t)j->start) return 1;
return 0;
});

fclose(fp);
return regions;
Expand Down Expand Up @@ -234,4 +241,4 @@ RuntimeModule ProcessRuntimeUtility::GetProcessModule(const char *name) {
}
}
return RuntimeModule{0};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ bool NearBranchTrampolinePlugin::GenerateTrampolineBuffer(InterceptRouting *rout

// generate trampoline, patch the original entry
bool NearBranchTrampolinePlugin::Active(InterceptRouting *routing) {
addr_t src, dst;
InterceptEntry *entry = routing->GetInterceptEntry();
src = (addr_t)entry->patched_addr;
dst = (addr_t)routing->GetTrampolineTarget();
return true;
}

0 comments on commit f652f0c

Please sign in to comment.