diff options
Diffstat (limited to 'ptw32_new.c')
-rw-r--r-- | ptw32_new.c | 15 |
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; } } |