summaryrefslogtreecommitdiff
path: root/ptw32_new.c
diff options
context:
space:
mode:
authorrpj <rpj>2003-08-14 08:53:17 +0000
committerrpj <rpj>2003-08-14 08:53:17 +0000
commita50745ec922a917513029f3f87bf820827b43f29 (patch)
tree1e221862e0550d163baef12d17634430ae677824 /ptw32_new.c
parent414f4bd7e70d94025576d9264c86da63c506f6ca (diff)
Reuse of thread IDs, improved thread ID validation, new tests, bug fixes.
Diffstat (limited to 'ptw32_new.c')
-rw-r--r--ptw32_new.c15
1 files changed, 13 insertions, 2 deletions
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;
}
}