diff options
Diffstat (limited to 'odb/details/win32/tls.txx')
-rw-r--r-- | odb/details/win32/tls.txx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/odb/details/win32/tls.txx b/odb/details/win32/tls.txx index f20b6a9..025e7cb 100644 --- a/odb/details/win32/tls.txx +++ b/odb/details/win32/tls.txx @@ -26,9 +26,8 @@ namespace odb get () const { once_.call (key_init); - void* v (_get (key_)); - if (v != 0) + if (void* v = _get (key_)) return *static_cast<T*> (v); auto_ptr<T> p (new T); @@ -41,6 +40,19 @@ namespace odb template <typename T> void tls<T>:: + free () + { + once_.call (key_init); + + if (void* v = _get (key_)) + { + _set (key_, 0); + delete static_cast<T*> (v); + } + } + + template <typename T> + void tls<T>:: key_init () { key_ = _allocate (destructor); |