https://github.com/openjdk/jdk/blob/6a7c023796b0f39f54d0335f4723c1f06ff0032d/src/hotspot/os/posix/perfMemory_posix.cpp#L1162-L1181
We are calling with THREAD and checking for error/exceptions explicitly. There's no need to use NEW_RESOURCE_ARRAY here
char* filename = get_sharedmem_filename(dirname, vmid, nspid);
// copy heap memory to resource memory. the open_sharedmem_file
// method below need to use the filename, but could throw an
// exception. using a resource array prevents the leak that
// would otherwise occur.
char* rfilename = NEW_RESOURCE_ARRAY(char, strlen(filename) + 1);
strcpy(rfilename, filename);
// free the c heap resources that are no longer needed
if (luser != user) FREE_C_HEAP_ARRAY(char, luser);
FREE_C_HEAP_ARRAY(char, dirname);
FREE_C_HEAP_ARRAY(char, filename);
// open the shared memory file for the give vmid
fd = open_sharedmem_file(rfilename, file_flags, THREAD);
if (fd == OS_ERR) {
return;
}
We are calling with THREAD and checking for error/exceptions explicitly. There's no need to use NEW_RESOURCE_ARRAY here
char* filename = get_sharedmem_filename(dirname, vmid, nspid);
// copy heap memory to resource memory. the open_sharedmem_file
// method below need to use the filename, but could throw an
// exception. using a resource array prevents the leak that
// would otherwise occur.
char* rfilename = NEW_RESOURCE_ARRAY(char, strlen(filename) + 1);
strcpy(rfilename, filename);
// free the c heap resources that are no longer needed
if (luser != user) FREE_C_HEAP_ARRAY(char, luser);
FREE_C_HEAP_ARRAY(char, dirname);
FREE_C_HEAP_ARRAY(char, filename);
// open the shared memory file for the give vmid
fd = open_sharedmem_file(rfilename, file_flags, THREAD);
if (fd == OS_ERR) {
return;
}