Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: nspr/pr/src/threads/combined/prucv.c

Issue 200653003: Update to NSPR 4.10.4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « nspr/pr/src/pthreads/ptthread.c ('k') | nspr/pr/src/threads/combined/prulock.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nspr/pr/src/threads/combined/prucv.c
===================================================================
--- nspr/pr/src/threads/combined/prucv.c (revision 257452)
+++ nspr/pr/src/threads/combined/prucv.c (working copy)
@@ -446,31 +446,37 @@
{
PRCondVar *cvar;
- PR_ASSERT(lock != NULL);
-
cvar = PR_NEWZAP(PRCondVar);
if (cvar) {
-#ifdef _PR_GLOBAL_THREADS_ONLY
- if(_PR_MD_NEW_CV(&cvar->md)) {
- PR_DELETE(cvar);
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
- return NULL;
- }
-#endif
- if (_PR_MD_NEW_LOCK(&(cvar->ilock)) == PR_FAILURE) {
- PR_DELETE(cvar);
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
- return NULL;
- }
- cvar->lock = lock;
- PR_INIT_CLIST(&cvar->condQ);
-
+ if (_PR_InitCondVar(cvar, lock) != PR_SUCCESS) {
+ PR_DELETE(cvar);
+ return NULL;
+ }
} else {
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
}
return cvar;
}
+PRStatus _PR_InitCondVar(PRCondVar *cvar, PRLock *lock)
+{
+ PR_ASSERT(lock != NULL);
+
+#ifdef _PR_GLOBAL_THREADS_ONLY
+ if(_PR_MD_NEW_CV(&cvar->md)) {
+ PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
+ return PR_FAILURE;
+ }
+#endif
+ if (_PR_MD_NEW_LOCK(&(cvar->ilock)) != PR_SUCCESS) {
+ PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
+ return PR_FAILURE;
+ }
+ cvar->lock = lock;
+ PR_INIT_CLIST(&cvar->condQ);
+ return PR_SUCCESS;
+}
+
/*
** Destroy a condition variable. There must be no thread
** waiting on the condvar. The caller is responsible for guaranteeing
@@ -479,14 +485,18 @@
*/
PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar *cvar)
{
+ _PR_FreeCondVar(cvar);
+ PR_DELETE(cvar);
+}
+
+void _PR_FreeCondVar(PRCondVar *cvar)
+{
PR_ASSERT(cvar->condQ.next == &cvar->condQ);
#ifdef _PR_GLOBAL_THREADS_ONLY
_PR_MD_FREE_CV(&cvar->md);
#endif
_PR_MD_FREE_LOCK(&(cvar->ilock));
-
- PR_DELETE(cvar);
}
/*
« no previous file with comments | « nspr/pr/src/pthreads/ptthread.c ('k') | nspr/pr/src/threads/combined/prulock.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698