aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat_winthreads.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-09-23 01:15:30 -0400
committerNick Mathewson <nickm@torproject.org>2015-01-14 10:49:59 -0500
commit65016304d23503e230e8b097b5cdc1e4897b9b57 (patch)
tree55dd1617de8d2994643a6e915bdd09a6165988d5 /src/common/compat_winthreads.c
parente865248156a8512d756be003118de446d29611d1 (diff)
downloadtor-65016304d23503e230e8b097b5cdc1e4897b9b57.tar.gz
tor-65016304d23503e230e8b097b5cdc1e4897b9b57.zip
Add tor_cond_init/uninit
Diffstat (limited to 'src/common/compat_winthreads.c')
-rw-r--r--src/common/compat_winthreads.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/common/compat_winthreads.c b/src/common/compat_winthreads.c
index 634dfbed30..11f91c63df 100644
--- a/src/common/compat_winthreads.c
+++ b/src/common/compat_winthreads.c
@@ -70,30 +70,25 @@ tor_get_thread_id(void)
return (unsigned long)GetCurrentThreadId();
}
-tor_cond_t *
-tor_cond_new(void)
+int
+tor_cond_init(tor_cond_t *cond)
{
- tor_cond_t *cond = tor_malloc(sizeof(tor_cond_t));
+ memset(cond, 0, sizeof(tor_cond_t));
if (InitializeCriticalSectionAndSpinCount(&cond->lock, SPIN_COUNT)==0) {
- tor_free(cond);
- return NULL;
+ return -1;
}
if ((cond->event = CreateEvent(NULL,TRUE,FALSE,NULL)) == NULL) {
DeleteCriticalSection(&cond->lock);
- tor_free(cond);
- return NULL;
+ return -1;
}
cond->n_waiting = cond->n_to_wake = cond->generation = 0;
- return cond;
+ return 0;
}
void
-tor_cond_free(tor_cond_t *cond)
+tor_cond_uninit(tor_cond_t *cond)
{
- if (!cond)
- return;
DeleteCriticalSection(&cond->lock);
CloseHandle(cond->event);
- mm_free(cond);
}
static void