diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-09-23 01:15:30 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-01-14 10:49:59 -0500 |
commit | 65016304d23503e230e8b097b5cdc1e4897b9b57 (patch) | |
tree | 55dd1617de8d2994643a6e915bdd09a6165988d5 /src/common/compat_pthreads.c | |
parent | e865248156a8512d756be003118de446d29611d1 (diff) | |
download | tor-65016304d23503e230e8b097b5cdc1e4897b9b57.tar.gz tor-65016304d23503e230e8b097b5cdc1e4897b9b57.zip |
Add tor_cond_init/uninit
Diffstat (limited to 'src/common/compat_pthreads.c')
-rw-r--r-- | src/common/compat_pthreads.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c index 0e5d33a659..e58b3f7b57 100644 --- a/src/common/compat_pthreads.c +++ b/src/common/compat_pthreads.c @@ -148,28 +148,23 @@ tor_get_thread_id(void) /* Conditions. */ -/** Return a newly allocated condition, with nobody waiting on it. */ -tor_cond_t * -tor_cond_new(void) +int +tor_cond_init(tor_cond_t *cond) { - tor_cond_t *cond = tor_malloc_zero(sizeof(tor_cond_t)); + memset(cond, 0, sizeof(tor_cond_t)); if (pthread_cond_init(&cond->cond, NULL)) { - tor_free(cond); - return NULL; + return -1; } - return cond; + return 0; } /** Release all resources held by <b>cond</b>. */ void -tor_cond_free(tor_cond_t *cond) +tor_cond_uninit(tor_cond_t *cond) { - if (!cond) - return; if (pthread_cond_destroy(&cond->cond)) { log_warn(LD_GENERAL,"Error freeing condition: %s", strerror(errno)); return; } - tor_free(cond); } /** Wait until one of the tor_cond_signal functions is called on <b>cond</b>. * All waiters on the condition must wait holding the same <b>mutex</b>. |