From a50745ec922a917513029f3f87bf820827b43f29 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 14 Aug 2003 08:53:17 +0000 Subject: Reuse of thread IDs, improved thread ID validation, new tests, bug fixes. --- ptw32_new.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'ptw32_new.c') diff --git a/ptw32_new.c b/ptw32_new.c index ca24ad7..5cbe0a7 100644 --- a/ptw32_new.c +++ b/ptw32_new.c @@ -43,7 +43,15 @@ ptw32_new (void) { pthread_t t; - t = (pthread_t) calloc (1, sizeof (*t)); + /* + * If there's a reusable pthread_t then use it. + */ + t = ptw32_threadReusePop(); + + if (NULL == t) + { + t = (pthread_t) calloc (1, sizeof (*t)); + } if (t != NULL) { @@ -59,7 +67,10 @@ ptw32_new (void) if (t->cancelEvent == NULL) { - free (t); + /* + * Thread ID structs are never freed. + */ + ptw32_threadReusePush(t); t = NULL; } } -- cgit v1.2.3