Skip to content
Snippets Groups Projects
Commit 11aa4a38 authored by Florian Fischer's avatar Florian Fischer
Browse files

[fsearch] close files after searching them

parent 7f845e8a
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ void search(const std::string& path) { ...@@ -38,7 +38,7 @@ void search(const std::string& path) {
while (bytes_read > 0) { while (bytes_read > 0) {
if (memmem(&buf[0], bytes_read, needle, needle_len)) { if (memmem(&buf[0], bytes_read, needle, needle_len)) {
printf("%s\n", path.c_str()); printf("%s\n", path.c_str());
return; goto out;
} }
bytes_searched += bytes_read; bytes_searched += bytes_read;
...@@ -48,6 +48,9 @@ void search(const std::string& path) { ...@@ -48,6 +48,9 @@ void search(const std::string& path) {
if (bytes_read < 0) { if (bytes_read < 0) {
DIE_MSG_ERRNO("read failed"); DIE_MSG_ERRNO("read failed");
} }
out:
emper::io::closeAndForget(fd);
} }
void walk_dir() { void walk_dir() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment