Author: czeidler Date: 2011-09-23 04:03:10 +0200 (Fri, 23 Sep 2011) New Revision: 42765 Changeset: https://dev.haiku-os.org/changeset/42765 Modified: haiku/trunk/headers/private/shared/WeakReferenceable.h Log: Use nothrow and add InitCheck method to check if allocation went fine. Modified: haiku/trunk/headers/private/shared/WeakReferenceable.h =================================================================== --- haiku/trunk/headers/private/shared/WeakReferenceable.h 2011-09-22 22:46:14 UTC (rev 42764) +++ haiku/trunk/headers/private/shared/WeakReferenceable.h 2011-09-23 02:03:10 UTC (rev 42765) @@ -8,7 +8,9 @@ #include <Referenceable.h> +#include <new> + namespace BPrivate { @@ -38,6 +40,8 @@ BWeakReferenceable(); virtual ~BWeakReferenceable(); + status_t InitCheck(); + void AcquireReference() { fPointer->GetUnchecked(); } @@ -243,7 +247,7 @@ inline BWeakReferenceable::BWeakReferenceable() : - fPointer(new WeakPointer(this)) + fPointer(new(std::nothrow) WeakPointer(this)) { } @@ -255,6 +259,15 @@ } +inline status_t +BWeakReferenceable::InitCheck() +{ + if (fPointer == NULL) + return B_NO_MEMORY; + return B_OK; +} + + inline WeakPointer* BWeakReferenceable::GetWeakPointer() {