From 0fcff08299c93ab75e5af2c9c88fc2d437c64c68 Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Fri, 4 Dec 1998 00:28:34 +0000 Subject: gthr-vxworks.h (__ehdtor): Fix memory leak. * gthr-vxworks.h (__ehdtor): Fix memory leak. The delete hook runs in the context of the deleter, not the deletee, so we must use taskVarGet to find the correct memory to free. (__gthread_key_create): Initialize the task variable subsystem so that the task variable is still active when the delete hook is run. From-SVN: r24079 --- gcc/gthr-vxworks.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'gcc/gthr-vxworks.h') diff --git a/gcc/gthr-vxworks.h b/gcc/gthr-vxworks.h index 9876646..6d51ded 100644 --- a/gcc/gthr-vxworks.h +++ b/gcc/gthr-vxworks.h @@ -60,11 +60,16 @@ extern __gthread_key_t eh_context_key; don't map well enough onto VxWorks. */ static void -__ehdtor () +__ehdtor (void *pTcb) { - if (eh_context_key) - free ((void*)eh_context_key); - eh_context_key = 0; + int tid = (int) pTcb; + void *p = (void*)taskVarGet(tid, &eh_context_key); + if (p != (void*)-1) + { + if (p) + free (p); + taskVarSet(tid, &eh_context_key, 0); + } } /* This only works for the code in libgcc2.c. */ @@ -74,6 +79,11 @@ __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *)) { *key = 0; + /* Do this first so that the task variables are visible during the + running of the delete hook. */ + + taskVarInit(); + /* We don't have a way to track dtor here, so instead, we register a generic routine that can cleanup any task. */ -- cgit v1.1