From: khizmax Date: Tue, 7 Apr 2015 13:57:49 +0000 (+0300) Subject: aligned allocator is raised std::bad_alloc when no memory X-Git-Tag: v2.1.0~267 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=708b700e321a3e09cff4321d3fe359e538c7f28c;p=libcds.git aligned allocator is raised std::bad_alloc when no memory --- diff --git a/cds/os/alloc_aligned.h b/cds/os/alloc_aligned.h index aa226f6f..1b285978 100644 --- a/cds/os/alloc_aligned.h +++ b/cds/os/alloc_aligned.h @@ -140,11 +140,16 @@ namespace cds { \code sizeof(T) % nAlign == 0 \endcode + + The function, like operator \p new does not return \p nullptr. + In no memory situation the function throws \p std::bad_alloc exception. */ pointer allocate( size_type nAlign, size_type nCount ) { assert( cds::beans::is_power2( nAlign ) ); pointer p = reinterpret_cast( cds::OS::aligned_malloc( sizeof(T) * nCount, nAlign ) ); + if ( !p ) + throw std::bad_alloc(); assert( cds::details::is_aligned( p, nAlign )); return p; }