2
0
mirror of https://github.com/boostorg/thread.git synced 2026-02-18 02:22:10 +00:00

Throw if malloc fails.

This commit is contained in:
Vicente J. Botet Escriba
2014-05-31 18:19:43 +02:00
parent 8c0640e5be
commit cb8a4a27bb

View File

@@ -11,6 +11,7 @@
#include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp>
#include <boost/thread/once.hpp>
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
#include <pthread.h>
#include <stdlib.h>
#include <memory>
@@ -67,6 +68,7 @@ namespace boost
if(!data)
{
data=malloc(sizeof(thread_detail::uintmax_atomic_t));
if(!data) BOOST_THROW_EXCEPTION(std::bad_alloc());
BOOST_VERIFY(!pthread_setspecific(epoch_tss_key,data));
*static_cast<thread_detail::uintmax_atomic_t*>(data)=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C;
}