@@ -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);
@@ -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