summaryrefslogtreecommitdiff
path: root/rwlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'rwlock.c')
-rw-r--r--rwlock.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/rwlock.c b/rwlock.c
index d02461c..4353847 100644
--- a/rwlock.c
+++ b/rwlock.c
@@ -94,8 +94,6 @@ pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
return EINVAL;
}
- rw = *rwlock;
-
rw = (pthread_rwlock_t) calloc(1, sizeof(*rw));
if (rw == NULL)
@@ -182,14 +180,19 @@ pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
}
else
{
+ /*
+ * Need to NULL this before we start freeing up
+ * and destroying it's components.
+ */
+ *rwlock = NULL;
rw->rw_magic = 0;
+
(void) pthread_mutex_unlock(&(rw->rw_lock));
+
(void) pthread_cond_destroy(&(rw->rw_condreaders));
(void) pthread_cond_destroy(&(rw->rw_condwriters));
(void) pthread_mutex_destroy(&(rw->rw_lock));
-
free(rw);
- *rwlock = NULL;
}
}
else