Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mbed-os-5.15] Replaced new calls with nothrow version of the call on mesh api #13954

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void ns_event_loop_thread_create(void)
EventQueue *equeue = mbed::mbed_event_queue();
MBED_ASSERT(equeue != NULL);

event = new Event<void()>(equeue, do_dispatch_with_mutex_held);
event = new (std::nothrow) Event<void()>(equeue, do_dispatch_with_mutex_held);
MBED_ASSERT(event != NULL);
}

Expand Down
11 changes: 6 additions & 5 deletions features/nanostack/nanostack-interface/Nanostack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ enum socket_mode_t {
class NanostackSocket {
public:
static void socket_callback(void *cb);
static void *operator new (std::size_t sz);
static void *operator new (std::size_t sz, const std::nothrow_t &nothrow_value) noexcept;
static void operator delete (void *ptr);

NanostackSocket(int8_t protocol);
Expand Down Expand Up @@ -205,10 +205,11 @@ static int nanostack_dns_query_result_check(const char *domain_name, SocketAddre
return -1;
}

void *NanostackSocket::operator new (std::size_t sz)
void *NanostackSocket::operator new (std::size_t sz, const std::nothrow_t &nothrow_value) noexcept
{
return MALLOC(sz);
}

void NanostackSocket::operator delete (void *ptr)
{
FREE(ptr);
Expand Down Expand Up @@ -534,7 +535,7 @@ nsapi_error_t Nanostack::call_in(int delay, mbed::Callback<void()> func)
}
}

nanostack_callback *cb = new nanostack_callback;
nanostack_callback *cb = new (std::nothrow) nanostack_callback;
if (!cb) {
return NSAPI_ERROR_NO_MEMORY;
}
Expand Down Expand Up @@ -687,7 +688,7 @@ nsapi_error_t Nanostack::socket_open(void **handle, nsapi_protocol_t protocol)

NanostackLockGuard lock;

NanostackSocket *socket = new NanostackSocket(ns_proto);
NanostackSocket *socket = new (std::nothrow) NanostackSocket(ns_proto);
if (socket == NULL) {
tr_debug("socket_open() ret=%i", NSAPI_ERROR_NO_MEMORY);
return NSAPI_ERROR_NO_MEMORY;
Expand Down Expand Up @@ -1125,7 +1126,7 @@ nsapi_error_t Nanostack::socket_accept(void *server, void **handle, SocketAddres
goto out;
}

accepted_sock = new NanostackSocket(socket->proto);
accepted_sock = new (std::nothrow) NanostackSocket(socket->proto);
if (accepted_sock == NULL) {
ret = NSAPI_ERROR_NO_MEMORY;
goto out;
Expand Down