aboutsummaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
authorKai WU <kaiwu2004@gmail.com>2022-03-15 22:33:45 +0800
committerKai WU <kaiwu2004@gmail.com>2022-03-15 22:33:45 +0800
commit480dfe85d94d703e10728f6a46cf05ee99ea08f8 (patch)
tree0fb33515b0957fa1cf6cd0328e964cf7e8fdc770 /src/common.cpp
parent82b7ecd721f21ff04eef695f16bd371dcca7b033 (diff)
downloadadvent-of-code-480dfe85d94d703e10728f6a46cf05ee99ea08f8.tar.gz
advent-of-code-480dfe85d94d703e10728f6a46cf05ee99ea08f8.zip
close fd
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp2
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;
}