@@ -71,7 +71,7 @@ enum socket_mode_t {
71
71
class NanostackSocket {
72
72
public:
73
73
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 ;
75
75
static void operator delete (void *ptr);
76
76
77
77
NanostackSocket (int8_t protocol);
@@ -205,10 +205,11 @@ static int nanostack_dns_query_result_check(const char *domain_name, SocketAddre
205
205
return -1 ;
206
206
}
207
207
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
209
209
{
210
210
return MALLOC (sz);
211
211
}
212
+
212
213
void NanostackSocket::operator delete (void *ptr)
213
214
{
214
215
FREE (ptr);
@@ -534,7 +535,7 @@ nsapi_error_t Nanostack::call_in(int delay, mbed::Callback<void()> func)
534
535
}
535
536
}
536
537
537
- nanostack_callback *cb = new nanostack_callback;
538
+ nanostack_callback *cb = new (std::nothrow) nanostack_callback;
538
539
if (!cb) {
539
540
return NSAPI_ERROR_NO_MEMORY;
540
541
}
@@ -687,7 +688,7 @@ nsapi_error_t Nanostack::socket_open(void **handle, nsapi_protocol_t protocol)
687
688
688
689
NanostackLockGuard lock;
689
690
690
- NanostackSocket *socket = new NanostackSocket (ns_proto);
691
+ NanostackSocket *socket = new (std::nothrow) NanostackSocket (ns_proto);
691
692
if (socket == NULL ) {
692
693
tr_debug (" socket_open() ret=%i" , NSAPI_ERROR_NO_MEMORY);
693
694
return NSAPI_ERROR_NO_MEMORY;
@@ -1125,7 +1126,7 @@ nsapi_error_t Nanostack::socket_accept(void *server, void **handle, SocketAddres
1125
1126
goto out;
1126
1127
}
1127
1128
1128
- accepted_sock = new NanostackSocket (socket->proto );
1129
+ accepted_sock = new (std::nothrow) NanostackSocket (socket->proto );
1129
1130
if (accepted_sock == NULL ) {
1130
1131
ret = NSAPI_ERROR_NO_MEMORY;
1131
1132
goto out;
0 commit comments