From 1b91c1dbea01681e0bd23042c7121196efb8a78a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 10 Dec 2009 20:34:46 +0000 Subject: [PATCH] Avoid static destruction order issues with quick_allocator. [SVN r58275] --- include/boost/smart_ptr/detail/quick_allocator.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/smart_ptr/detail/quick_allocator.hpp b/include/boost/smart_ptr/detail/quick_allocator.hpp index 6d136f8..159bd5e 100644 --- a/include/boost/smart_ptr/detail/quick_allocator.hpp +++ b/include/boost/smart_ptr/detail/quick_allocator.hpp @@ -74,8 +74,9 @@ template struct allocator_impl static lightweight_mutex & mutex() { - static lightweight_mutex m; - return m; + static freeblock< sizeof( lightweight_mutex ), boost::alignment_of< lightweight_mutex >::value > fbm; + static lightweight_mutex * pm = new( &fbm ) lightweight_mutex; + return *pm; } static lightweight_mutex * mutex_init;