This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] Destructor support for C++11 thread_local variables- abilist entries
On 10/12/2012 05:28 AM, Siddhesh Poyarekar wrote:
> +__call_tls_dtors (void)
> +{
> + struct dtor_list *l = tls_dtor_list;
> +
> + while (l)
> + {
> + struct dtor_list *cur = l;
> +
> + l = l->next;
> + cur->func (cur->obj);
> + free (cur);
> + }
> + tls_dtor_list = NULL;
> +}
I don't like leaving a stale pointer like this. And this ignores the
possibility of new items being added to the list during the list
destruction process.
Shall we write instead
while (tls_dtor_list)
{
struct dtor_list *cur = tls_dtor_list;
tls_dtor_list = cur->next;
cur->func (cur->obj);
free (cur);
}
This is much closer to how __run_exit_handlers is structured.
r~