Call "new" instead of no-throw version and the MBED_ERROR.

Standard new operator already calls MBED_ERROR in failure.
pull/9424/head
Seppo Takalo 2019-01-31 15:21:12 +02:00
parent 86019af7eb
commit 06aea98f99
1 changed files with 1 additions and 5 deletions

View File

@ -105,11 +105,7 @@ static void call_all_event_listeners(NetworkInterface *iface, nsapi_event_t even
void NetworkInterface::add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb)
{
iface_eventlist_t *event_list = get_interface_event_list_head();
iface_eventlist_entry_t *entry = new (std::nothrow) iface_eventlist_entry_t;
if (!entry) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_NETWORK_STACK, MBED_ERROR_CODE_ENOMEM), "Failed to allocate entry");
return;
}
iface_eventlist_entry_t *entry = new iface_eventlist_entry_t;
entry->iface = this;
entry->status_cb = status_cb;
ns_list_add_to_end(event_list, entry);