Boost logo

Boost :

From: Christof Meerwald (cmeerw_at_[hidden])
Date: 2002-06-10 10:31:42


currently, detail::tss::set doesn't remove the previously registered
cleanup handler if the new value is a NULL pointer. So if you reset
a thread_specific_pointer with a NULL pointer (or release it) and don't
set any other value before the thread terminates, the initial pointer
will be deleted twice (once by thread_specific_pointer::reset and again
by the cleanup handler).

Shouldn't the implementation of tss::set (for Win32) be changed to
something like (completely untested):

bool tss::set(void* value)
    if (m_cleanup)
        cleanup_handlers* handlers = get_handlers();
        if (!handlers)
            return false;
        if (value)
            cleanup_info info(m_cleanup, value);
            (*handlers)[m_key] = info;
        else if (TlsGetValue(m_key))
    return !!TlsSetValue(m_key, value);

bye, Christof

--                                 JID: cmeerw_at_[hidden]
mailto cmeerw at

Boost list run by bdawes at, gregod at, cpdaniel at, john at