aligned allocator is raised std::bad_alloc when no memory
authorkhizmax <khizmax@gmail.com>
Tue, 7 Apr 2015 13:57:49 +0000 (16:57 +0300)
committerkhizmax <khizmax@gmail.com>
Tue, 7 Apr 2015 13:57:49 +0000 (16:57 +0300)
cds/os/alloc_aligned.h

index aa226f6f7d8c6e19153db89b22aa7668ca2c6ba2..1b28597871c63035fbd7b3bcc2c6cde4df1f6fb1 100644 (file)
@@ -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<T *>( cds::OS::aligned_malloc( sizeof(T) * nCount, nAlign ) );
+                if ( !p )
+                    throw std::bad_alloc();
                 assert( cds::details::is_aligned( p, nAlign ));
                 return p;
             }