@@ -71,7 +71,7 @@ enum socket_mode_t {
7171class NanostackSocket {
7272public:
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 ¬hrow_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 ¬hrow_value) noexcept
209209{
210210 return MALLOC (sz);
211211}
212+
212213void NanostackSocket::operator delete (void *ptr)
213214{
214215 FREE (ptr);
@@ -533,7 +534,7 @@ nsapi_error_t Nanostack::call_in(int delay, mbed::Callback<void()> func)
533534 }
534535 }
535536
536- nanostack_callback *cb = new nanostack_callback;
537+ nanostack_callback *cb = new (std::nothrow) nanostack_callback;
537538 if (!cb) {
538539 return NSAPI_ERROR_NO_MEMORY;
539540 }
@@ -685,7 +686,7 @@ nsapi_error_t Nanostack::socket_open(void **handle, nsapi_protocol_t protocol)
685686
686687 NanostackLockGuard lock;
687688
688- NanostackSocket *socket = new NanostackSocket (ns_proto);
689+ NanostackSocket *socket = new (std::nothrow) NanostackSocket (ns_proto);
689690 if (socket == NULL ) {
690691 tr_debug (" socket_open() ret=%i" , NSAPI_ERROR_NO_MEMORY);
691692 return NSAPI_ERROR_NO_MEMORY;
@@ -1123,7 +1124,7 @@ nsapi_error_t Nanostack::socket_accept(void *server, void **handle, SocketAddres
11231124 goto out;
11241125 }
11251126
1126- accepted_sock = new NanostackSocket (socket->proto );
1127+ accepted_sock = new (std::nothrow) NanostackSocket (socket->proto );
11271128 if (accepted_sock == NULL ) {
11281129 ret = NSAPI_ERROR_NO_MEMORY;
11291130 goto out;
0 commit comments