Skip to content

Commit

Permalink
mmapifstream: don't fail if file is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ligfx committed May 11, 2021
1 parent b010259 commit f00cfbd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils/mmapifstream.cpp
Expand Up @@ -56,6 +56,9 @@ mmapifstream::mmapifstream(const std::string& filename) {
fseek(f, 0, SEEK_END);
filesize = ftell(f);
assert((int)filesize != -1);
if (filesize == 0) {
return;
}

void* mapr = mmap(0, filesize, PROT_READ, MAP_PRIVATE, fno, 0);
fclose(f); // we don't need it, now!
Expand Down

0 comments on commit f00cfbd

Please sign in to comment.