Skip to content

Commit

Permalink
Avoid intermediate buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
rocallahan committed Nov 1, 2023
1 parent c835873 commit 28226b8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/AddressSpace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,14 @@ vector<uint8_t> AddressSpace::read_rr_page_for_recording(SupportedArch arch) {
}

ScopedFd page(path.c_str(), O_RDONLY);
char buf[PRELOAD_LIBRARY_PAGE_SIZE];
vector<uint8_t> result;
result.resize(PRELOAD_LIBRARY_PAGE_SIZE);
ssize_t ret = read_to_end(page,
RRPAGE_RECORD_PAGE_OFFSET * PRELOAD_LIBRARY_PAGE_SIZE, buf, sizeof(buf));
if (ret != PRELOAD_LIBRARY_PAGE_SIZE) {
RRPAGE_RECORD_PAGE_OFFSET * PRELOAD_LIBRARY_PAGE_SIZE, result.data(),
result.size());
if (ret != static_cast<ssize_t>(result.size())) {
FATAL() << "Failed to read full page from " << path;
}
vector<uint8_t> result;
result.insert(result.end(), buf, buf + sizeof(buf));
return result;
}

Expand Down

0 comments on commit 28226b8

Please sign in to comment.