From 708b700e321a3e09cff4321d3fe359e538c7f28c Mon Sep 17 00:00:00 2001 From: khizmax Date: Tue, 7 Apr 2015 16:57:49 +0300 Subject: [PATCH] aligned allocator is raised std::bad_alloc when no memory --- cds/os/alloc_aligned.h | 5 +++++ 1 file changed, 5 insertions(+) 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; } -- 2.34.1