summaryrefslogtreecommitdiff
path: root/mutex.c
diff options
context:
space:
mode:
authorrpj <rpj>1999-09-11 10:53:22 +0000
committerrpj <rpj>1999-09-11 10:53:22 +0000
commitddce48cadf17ad0b75d6c57062106b700a73d738 (patch)
treefb082f0d90635dc75dc646b5e91f1c03af30dfa7 /mutex.c
parent4cd9537cd00fcbab78c1e0d2125dac4a9117e815 (diff)
Sat Sep 10 12:56:13 1999 Ross Johnson <rpj@swan.canberra.edu.au>
* mutex.c (pthread_mutex_destroy): Don't free mutex memory if mutex is PTHREAD_MUTEX_INITIALIZER and has not been initialised yet.
Diffstat (limited to 'mutex.c')
-rw-r--r--mutex.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/mutex.c b/mutex.c
index 2259713..be68f5b 100644
--- a/mutex.c
+++ b/mutex.c
@@ -192,12 +192,20 @@ pthread_mutex_destroy(pthread_mutex_t *mutex)
{
result = (CloseHandle (mx->mutex) ? 0 : EINVAL);
}
- }
- if (result == 0)
+ if (result == 0)
+ {
+ mx->mutex = 0;
+ free(mx);
+ *mutex = NULL;
+ }
+ }
+ else
{
- mx->mutex = 0;
- free(mx);
+ /*
+ * This is all we need to do to destroy a statically
+ * initialised mutex that has not yet been used (initialised).
+ */
*mutex = NULL;
}