Skip to content

Commit

Permalink
new operator cannot return nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajmund Szymański committed Jun 18, 2023
1 parent ceb9708 commit 881e328
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions stateos/kernel/inc/osbarrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osbarrier.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -350,7 +350,7 @@ struct Barrier : public __bar
static
Ptr Create( const unsigned _limit )
{
auto bar = new Barrier(_limit);
auto bar = new (std::nothrow) Barrier(_limit);
if (bar != nullptr)
bar->__bar::obj.res = bar;
return Ptr(bar);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/osconditionvariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osconditionvariable.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -445,7 +445,7 @@ struct ConditionVariable : public __cnd
static
Ptr Create()
{
auto cnd = new ConditionVariable();
auto cnd = new (std::nothrow) ConditionVariable();
if (cnd != nullptr)
cnd->__cnd::obj.res = cnd;
return Ptr(cnd);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/osevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osevent.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -368,7 +368,7 @@ struct Event : public __evt
static
Ptr Create()
{
auto evt = new Event();
auto evt = new (std::nothrow) Event();
if (evt != nullptr)
evt->__evt::obj.res = evt;
return Ptr(evt);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/oseventqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: oseventqueue.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -666,7 +666,7 @@ struct EventQueueT : public __evq
static
Ptr Create()
{
auto evq = new EventQueueT<limit_>();
auto evq = new (std::nothrow) EventQueueT<limit_>();
if (evq != nullptr)
evq->__evq::obj.res = evq;
return Ptr(evq);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/osfastmutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osfastmutex.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -408,7 +408,7 @@ struct FastMutex : public __mut
static
Ptr Create()
{
auto mut = new FastMutex();
auto mut = new (std::nothrow) FastMutex();
if (mut != nullptr)
mut->__mut::obj.res = mut;
return Ptr(mut);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/osflag.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osflag.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -512,7 +512,7 @@ struct Flag : public __flg
static
Ptr Create( const unsigned _init = 0 )
{
auto flg = new Flag(_init);
auto flg = new (std::nothrow) Flag(_init);
if (flg != nullptr)
flg->__flg::obj.res = flg;
return Ptr(flg);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/osjobqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osjobqueue.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -662,7 +662,7 @@ struct JobQueueT : public __job
static
Ptr Create()
{
auto job = new JobQueueT<limit_>();
auto job = new (std::nothrow) JobQueueT<limit_>();
if (job != nullptr)
job->__job::obj.res = job;
return Ptr(job);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/oslist.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: oslist.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -435,7 +435,7 @@ struct ListTT : public __lst
static
Ptr Create()
{
auto lst = new ListTT<C>();
auto lst = new (std::nothrow) ListTT<C>();
if (lst != nullptr)
lst->__lst::obj.res = lst;
return Ptr(lst);
Expand Down
6 changes: 3 additions & 3 deletions stateos/kernel/inc/osmailboxqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osmailboxqueue.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -702,7 +702,7 @@ struct MailBoxQueueT : public __box
static
Ptr Create()
{
auto box = new MailBoxQueueT<limit_, size_>();
auto box = new (std::nothrow) MailBoxQueueT<limit_, size_>();
if (box != nullptr)
box->__box::obj.res = box;
return Ptr(box);
Expand Down Expand Up @@ -755,7 +755,7 @@ struct MailBoxQueueTT : public MailBoxQueueT<limit_, sizeof(C)>
static
Ptr Create()
{
auto box = new MailBoxQueueTT<limit_, C>();
auto box = new (std::nothrow) MailBoxQueueTT<limit_, C>();
if (box != nullptr)
box->__box::obj.res = box;
return Ptr(box);
Expand Down
6 changes: 3 additions & 3 deletions stateos/kernel/inc/osmemorypool.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osmemorypool.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -469,7 +469,7 @@ struct MemoryPoolT : public __mem
static
Ptr Create()
{
auto mem = new MemoryPoolT<limit_, size_>();
auto mem = new (std::nothrow) MemoryPoolT<limit_, size_>();
if (mem != nullptr)
mem->__mem::lst.obj.res = mem;
return Ptr(mem);
Expand Down Expand Up @@ -530,7 +530,7 @@ struct MemoryPoolTT : public MemoryPoolT<limit_, sizeof(C)>
static
Ptr Create()
{
auto mem = new MemoryPoolTT<limit_, C>();
auto mem = new (std::nothrow) MemoryPoolTT<limit_, C>();
if (mem != nullptr)
mem->__mem::lst.obj.res = mem;
return Ptr(mem);
Expand Down
6 changes: 3 additions & 3 deletions stateos/kernel/inc/osmessagequeue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osmessagequeue.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -744,7 +744,7 @@ struct MessageQueueT : public __msg
static
Ptr Create()
{
auto msg = new MessageQueueT<limit_, size_>();
auto msg = new (std::nothrow) MessageQueueT<limit_, size_>();
if (msg != nullptr)
msg->__msg::obj.res = msg;
return Ptr(msg);
Expand Down Expand Up @@ -821,7 +821,7 @@ struct MessageQueueTT : public MessageQueueT<limit_, sizeof(C)>
static
Ptr Create()
{
auto msg = new MessageQueueTT<limit_, C>();
auto msg = new (std::nothrow) MessageQueueTT<limit_, C>();
if (msg != nullptr)
msg->__msg::obj.res = msg;
return Ptr(msg);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/osmutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osmutex.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -536,7 +536,7 @@ struct Mutex : public __mtx
static
Ptr Create( const unsigned _mode, const unsigned _prio = 0 )
{
auto mtx = new Mutex(_mode, _prio);
auto mtx = new (std::nothrow) Mutex(_mode, _prio);
if (mtx != nullptr)
mtx->__mtx::obj.res = mtx;
return Ptr(mtx);
Expand Down
6 changes: 3 additions & 3 deletions stateos/kernel/inc/osrawbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osrawbuffer.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -671,7 +671,7 @@ struct RawBufferT : public __raw
static
Ptr Create()
{
auto raw = new RawBufferT<limit_>();
auto raw = new (std::nothrow) RawBufferT<limit_>();
if (raw != nullptr)
raw->__raw::obj.res = raw;
return Ptr(raw);
Expand Down Expand Up @@ -742,7 +742,7 @@ struct RawBufferTT : public RawBufferT<limit_*sizeof(C)>
static
Ptr Create()
{
auto raw = new RawBufferTT<limit_, C>();
auto raw = new (std::nothrow) RawBufferTT<limit_, C>();
if (raw != nullptr)
raw->__raw::obj.res = raw;
return Ptr(raw);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/osrwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osrwlock.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -534,7 +534,7 @@ struct RWLock : public __rwl
static
Ptr Create()
{
auto rwl = new RWLock();
auto rwl = new (std::nothrow) RWLock();
if (rwl != nullptr)
rwl->__rwl::obj.res = rwl;
return Ptr(rwl);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/ossemaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: ossemaphore.h
@author Rajmund Szymanski
@date 26.07.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -595,7 +595,7 @@ struct Semaphore : public __sem
static
Ptr Create( const unsigned _init, const unsigned _limit = semDefault )
{
auto sem = new Semaphore(_init, _limit);
auto sem = new (std::nothrow) Semaphore(_init, _limit);
if (sem != nullptr)
sem->__sem::obj.res = sem;
return Ptr(sem);
Expand Down
4 changes: 2 additions & 2 deletions stateos/kernel/inc/ossignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: ossignal.h
@author Rajmund Szymanski
@date 18.03.2023
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -468,7 +468,7 @@ struct Signal : public __sig
static
Ptr Create( const unsigned _mask = 0 )
{
auto sig = new Signal(_mask);
auto sig = new (std::nothrow) Signal(_mask);
if (sig != nullptr)
sig->__sig::obj.res = sig;
return Ptr(sig);
Expand Down
6 changes: 3 additions & 3 deletions stateos/kernel/inc/osstatemachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: osstatemachine.h
@author Rajmund Szymanski
@date 01.08.2022
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -848,7 +848,7 @@ struct StateMachineT : public __hsm
static
Ptr Create()
{
auto hsm = new StateMachineT<limit_>();
auto hsm = new (std::nothrow) StateMachineT<limit_>();
if (hsm != nullptr)
hsm->__hsm::evq.obj.res = hsm;
return Ptr(hsm);
Expand All @@ -857,7 +857,7 @@ struct StateMachineT : public __hsm
static
Ptr Create( const std::vector<Action>& _tab )
{
auto hsm = new StateMachineT<limit_>(_tab);
auto hsm = new (std::nothrow) StateMachineT<limit_>(_tab);
if (hsm != nullptr)
hsm->__hsm::evq.obj.res = hsm;
return Ptr(hsm);
Expand Down
6 changes: 3 additions & 3 deletions stateos/kernel/inc/ostask.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file StateOS: ostask.h
@author Rajmund Szymanski
@date 18.03.2023
@date 18.06.2023
@brief This file contains definitions for StateOS.
******************************************************************************
Expand Down Expand Up @@ -1429,7 +1429,7 @@ struct TaskT : public baseTask, public baseStack<size_>
template<class F> static
Ptr Create( const unsigned _prio, F&& _proc )
{
auto tsk = new TaskT<size_>(_prio, _proc);
auto tsk = new (std::nothrow) TaskT<size_>(_prio, _proc);
if (tsk != nullptr)
{
tsk->__tsk::obj.res = tsk;
Expand Down Expand Up @@ -1483,7 +1483,7 @@ struct TaskT : public baseTask, public baseStack<size_>
template<class F> static
Ptr Detached( const unsigned _prio, F&& _proc )
{
auto tsk = new TaskT<size_>(_prio, _proc);
auto tsk = new (std::nothrow) TaskT<size_>(_prio, _proc);
if (tsk != nullptr)
{
tsk->__tsk::obj.res = tsk;
Expand Down
Loading

0 comments on commit 881e328

Please sign in to comment.