From ddce48cadf17ad0b75d6c57062106b700a73d738 Mon Sep 17 00:00:00 2001 From: rpj Date: Sat, 11 Sep 1999 10:53:22 +0000 Subject: Sat Sep 10 12:56:13 1999 Ross Johnson * mutex.c (pthread_mutex_destroy): Don't free mutex memory if mutex is PTHREAD_MUTEX_INITIALIZER and has not been initialised yet. --- ChangeLog | 6 ++++++ mutex.c | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49dc36c..7309f0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Sep 10 12:56:13 1999 Ross Johnson + + * mutex.c (pthread_mutex_destroy): Don't free mutex memory + if mutex is PTHREAD_MUTEX_INITIALIZER and has not been + initialised yet. + Wed Sep 8 12:56:13 1999 Ross Johnson * mutex.c (pthread_mutex_destroy): Free mutex memory. 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; } -- cgit v1.2.3