diff options
author | Kai WU <kaiwu2004@gmail.com> | 2022-03-15 22:33:45 +0800 |
---|---|---|
committer | Kai WU <kaiwu2004@gmail.com> | 2022-03-15 22:33:45 +0800 |
commit | 480dfe85d94d703e10728f6a46cf05ee99ea08f8 (patch) | |
tree | 0fb33515b0957fa1cf6cd0328e964cf7e8fdc770 /src/common.cpp | |
parent | 82b7ecd721f21ff04eef695f16bd371dcca7b033 (diff) | |
download | advent-of-code-480dfe85d94d703e10728f6a46cf05ee99ea08f8.tar.gz advent-of-code-480dfe85d94d703e10728f6a46cf05ee99ea08f8.zip |
close fd
Diffstat (limited to 'src/common.cpp')
-rw-r--r-- | src/common.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp index d608a22..8442bf6 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -3,6 +3,7 @@ #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> +#include <unistd.h> line_view load_file(const char* path) { int fd; @@ -16,6 +17,7 @@ line_view load_file(const char* path) { line_view lv; lv.length = fs.st_size; lv.line = static_cast<const char*>(mmap(NULL, lv.length, PROT_READ, MAP_PRIVATE, fd, 0)); + close(fd); return lv; } |