mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 00:54:38 +02:00
8296453: Simplify resource_area uses in ClassPathDirEntry::open_stream
Reviewed-by: dholmes, phh
This commit is contained in:
parent
95c390ec75
commit
2159170b41
4 changed files with 17 additions and 10 deletions
|
@ -255,7 +255,7 @@ ClassFileStream* ClassPathDirEntry::open_stream(JavaThread* current, const char*
|
|||
int file_handle = os::open(path, 0, 0);
|
||||
if (file_handle != -1) {
|
||||
// read contents into resource array
|
||||
u1* buffer = NEW_RESOURCE_ARRAY(u1, st.st_size);
|
||||
u1* buffer = NEW_RESOURCE_ARRAY_IN_THREAD(current, u1, st.st_size);
|
||||
size_t num_read = ::read(file_handle, (char*) buffer, st.st_size);
|
||||
// close file
|
||||
::close(file_handle);
|
||||
|
@ -264,7 +264,11 @@ ClassFileStream* ClassPathDirEntry::open_stream(JavaThread* current, const char*
|
|||
if (UsePerfData) {
|
||||
ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read);
|
||||
}
|
||||
FREE_RESOURCE_ARRAY(char, path, path_len);
|
||||
#ifdef ASSERT
|
||||
// Freeing path is a no-op here as buffer prevents it from being reclaimed. But we keep it for
|
||||
// debug builds so that we guard against use-after-free bugs.
|
||||
FREE_RESOURCE_ARRAY_IN_THREAD(current, char, path, path_len);
|
||||
#endif
|
||||
// Resource allocated
|
||||
return new ClassFileStream(buffer,
|
||||
st.st_size,
|
||||
|
@ -273,7 +277,7 @@ ClassFileStream* ClassPathDirEntry::open_stream(JavaThread* current, const char*
|
|||
}
|
||||
}
|
||||
}
|
||||
FREE_RESOURCE_ARRAY(char, path, path_len);
|
||||
FREE_RESOURCE_ARRAY_IN_THREAD(current, char, path, path_len);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue