Skip to content

Commit 66e1044

Browse files
authored
Merge pull request #13954 from mikaleppanen/new_to_nothrow_5_15
[mbed-os-5.15] Replaced new calls with nothrow version of the call on mesh api
2 parents d02756f + 82e9f8d commit 66e1044

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

features/nanostack/nanostack-hal-mbed-cmsis-rtos/ns_event_loop_mbed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void ns_event_loop_thread_create(void)
8787
EventQueue *equeue = mbed::mbed_event_queue();
8888
MBED_ASSERT(equeue != NULL);
8989

90-
event = new Event<void()>(equeue, do_dispatch_with_mutex_held);
90+
event = new (std::nothrow) Event<void()>(equeue, do_dispatch_with_mutex_held);
9191
MBED_ASSERT(event != NULL);
9292
}
9393

features/nanostack/nanostack-interface/Nanostack.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ enum socket_mode_t {
7171
class NanostackSocket {
7272
public:
7373
static void socket_callback(void *cb);
74-
static void *operator new (std::size_t sz);
74+
static void *operator new (std::size_t sz, const std::nothrow_t &nothrow_value) noexcept;
7575
static void operator delete (void *ptr);
7676

7777
NanostackSocket(int8_t protocol);
@@ -205,10 +205,11 @@ static int nanostack_dns_query_result_check(const char *domain_name, SocketAddre
205205
return -1;
206206
}
207207

208-
void *NanostackSocket::operator new (std::size_t sz)
208+
void *NanostackSocket::operator new (std::size_t sz, const std::nothrow_t &nothrow_value) noexcept
209209
{
210210
return MALLOC(sz);
211211
}
212+
212213
void NanostackSocket::operator delete (void *ptr)
213214
{
214215
FREE(ptr);
@@ -534,7 +535,7 @@ nsapi_error_t Nanostack::call_in(int delay, mbed::Callback<void()> func)
534535
}
535536
}
536537

537-
nanostack_callback *cb = new nanostack_callback;
538+
nanostack_callback *cb = new (std::nothrow) nanostack_callback;
538539
if (!cb) {
539540
return NSAPI_ERROR_NO_MEMORY;
540541
}
@@ -687,7 +688,7 @@ nsapi_error_t Nanostack::socket_open(void **handle, nsapi_protocol_t protocol)
687688

688689
NanostackLockGuard lock;
689690

690-
NanostackSocket *socket = new NanostackSocket(ns_proto);
691+
NanostackSocket *socket = new (std::nothrow) NanostackSocket(ns_proto);
691692
if (socket == NULL) {
692693
tr_debug("socket_open() ret=%i", NSAPI_ERROR_NO_MEMORY);
693694
return NSAPI_ERROR_NO_MEMORY;
@@ -1125,7 +1126,7 @@ nsapi_error_t Nanostack::socket_accept(void *server, void **handle, SocketAddres
11251126
goto out;
11261127
}
11271128

1128-
accepted_sock = new NanostackSocket(socket->proto);
1129+
accepted_sock = new (std::nothrow) NanostackSocket(socket->proto);
11291130
if (accepted_sock == NULL) {
11301131
ret = NSAPI_ERROR_NO_MEMORY;
11311132
goto out;

0 commit comments

Comments
 (0)