mirror of
https://github.com/reactos/ccache.git
synced 2025-01-24 04:14:31 +00:00
Always close(fd) as soon as file is mmap()'d.
This commit is contained in:
parent
1c31b315b4
commit
38926cce43
3
ccache.c
3
ccache.c
@ -348,6 +348,7 @@ static void remember_include_file(char *path, size_t path_len)
|
||||
goto failure;
|
||||
}
|
||||
data = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
close(fd);
|
||||
if (data == (char *)-1) {
|
||||
cc_log("Failed to mmap %s", path);
|
||||
goto failure;
|
||||
@ -422,11 +423,11 @@ static int process_preprocessed_file(struct mdfour *hash, const char *path)
|
||||
}
|
||||
size = st.st_size;
|
||||
data = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
close(fd);
|
||||
if (data == (void *)-1) {
|
||||
cc_log("Failed to mmap %s", path);
|
||||
return 0;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
if (enable_direct) {
|
||||
included_files = create_hashtable(1000, hash_from_string,
|
||||
|
2
unify.c
2
unify.c
@ -261,11 +261,11 @@ int unify_hash(struct mdfour *hash, const char *fname)
|
||||
lines in preprocessor output. I have seen lines of over
|
||||
100k in length, so this is well worth it */
|
||||
map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
close(fd);
|
||||
if (map == (char *)-1) {
|
||||
cc_log("Failed to mmap %s", fname);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
/* pass it through the unifier */
|
||||
unify(hash, (unsigned char *)map, st.st_size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user