Index: nspr/pr/src/threads/combined/prulock.c |
=================================================================== |
--- nspr/pr/src/threads/combined/prulock.c (revision 257452) |
+++ nspr/pr/src/threads/combined/prulock.c (working copy) |
@@ -160,16 +160,24 @@ |
lock = PR_NEWZAP(PRLock); |
if (lock) { |
- if (_PR_MD_NEW_LOCK(&lock->ilock) == PR_FAILURE) { |
- PR_DELETE(lock); |
- return(NULL); |
- } |
- PR_INIT_CLIST(&lock->links); |
- PR_INIT_CLIST(&lock->waitQ); |
+ if (_PR_InitLock(lock) != PR_SUCCESS) { |
+ PR_DELETE(lock); |
+ return NULL; |
+ } |
} |
return lock; |
} |
+PRStatus _PR_InitLock(PRLock *lock) |
+{ |
+ if (_PR_MD_NEW_LOCK(&lock->ilock) != PR_SUCCESS) { |
+ return PR_FAILURE; |
+ } |
+ PR_INIT_CLIST(&lock->links); |
+ PR_INIT_CLIST(&lock->waitQ); |
+ return PR_SUCCESS; |
+} |
+ |
/* |
** Destroy the given lock "lock". There is no point in making this race |
** free because if some other thread has the pointer to this lock all |
@@ -177,11 +185,16 @@ |
*/ |
PR_IMPLEMENT(void) PR_DestroyLock(PRLock *lock) |
{ |
- PR_ASSERT(lock->owner == 0); |
- _PR_MD_FREE_LOCK(&lock->ilock); |
+ _PR_FreeLock(lock); |
PR_DELETE(lock); |
} |
+void _PR_FreeLock(PRLock *lock) |
+{ |
+ PR_ASSERT(lock->owner == 0); |
+ _PR_MD_FREE_LOCK(&lock->ilock); |
+} |
+ |
extern PRThread *suspendAllThread; |
/* |
** Lock the lock. |