kernel: follow-up to hrev56619: use new(std::nothrow)

to handle allocation failures.

Change-Id: I15d84b24dcea17741382b1d5285acf6219a39811
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5868
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
X512 2022-11-30 20:16:30 +09:00 committed by waddlesplash
parent 07ca9bce14
commit f0e187c3fd
3 changed files with 4 additions and 4 deletions

View File

@ -1133,7 +1133,7 @@ start_watching(const char* base, const char* sub)
static struct driver_entry*
new_driver_entry(const char* path, dev_t device, ino_t node)
{
driver_entry* entry = new driver_entry;
driver_entry* entry = new(std::nothrow) driver_entry;
if (entry == NULL)
return NULL;
@ -1519,7 +1519,7 @@ legacy_driver_probe(const char* subPath)
extern "C" status_t
legacy_driver_init(void)
{
sDriverHash = new DriverTable();
sDriverHash = new(std::nothrow) DriverTable();
if (sDriverHash == NULL || sDriverHash->Init(DRIVER_HASH_SIZE) != B_OK)
return B_NO_MEMORY;

View File

@ -468,7 +468,7 @@ register_low_resource_handler(low_resource_func function, void* data,
TRACE(("register_low_resource_handler(function = %p, data = %p)\n",
function, data));
low_resource_handler *newHandler = new low_resource_handler;
low_resource_handler *newHandler = new(std::nothrow) low_resource_handler;
if (newHandler == NULL)
return B_NO_MEMORY;

View File

@ -1454,7 +1454,7 @@ swap_file_add(const char* path)
}
// do the allocations and prepare the swap_file structure
swap_file* swap = new swap_file;
swap_file* swap = new(std::nothrow) swap_file;
if (swap == NULL) {
close(fd);
return B_NO_MEMORY;