Use nothrow and add InitCheck method to check if allocation went fine.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42765 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler
2011-09-23 02:03:10 +00:00
parent a8e3ae78c9
commit ac80530495
+14 -1
View File
@@ -8,6 +8,8 @@
#include <Referenceable.h>
#include <new>
namespace BPrivate {
@@ -38,6 +40,8 @@ public:
BWeakReferenceable();
virtual ~BWeakReferenceable();
status_t InitCheck();
void AcquireReference()
{ fPointer->GetUnchecked(); }
@@ -243,7 +247,7 @@ WeakPointer::GetUnchecked()
inline
BWeakReferenceable::BWeakReferenceable()
:
fPointer(new WeakPointer(this))
fPointer(new(std::nothrow) WeakPointer(this))
{
}
@@ -255,6 +259,15 @@ BWeakReferenceable::~BWeakReferenceable()
}
inline status_t
BWeakReferenceable::InitCheck()
{
if (fPointer == NULL)
return B_NO_MEMORY;
return B_OK;
}
inline WeakPointer*
BWeakReferenceable::GetWeakPointer()
{