diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2009-09-28 16:37:01 +0200 |
---|---|---|
committer | Sebastian Hahn <sebastian@torproject.org> | 2009-12-12 03:29:44 +0100 |
commit | 3807db001d71c51e53c1897ae067671f5b771f2f (patch) | |
tree | 6c6f648f072d24e7bbf554de12519b27cd9ef888 /src/common/compat.c | |
parent | 4afdb79051f7b1caba49877fb57be60bda9d4514 (diff) | |
download | tor-3807db001d71c51e53c1897ae067671f5b771f2f.tar.gz tor-3807db001d71c51e53c1897ae067671f5b771f2f.zip |
*_free functions now accept NULL
Some *_free functions threw asserts when passed NULL. Now all of them
accept NULL as input and perform no action when called that way.
This gains us consistence for our free functions, and allows some
code simplifications where an explicit null check is no longer necessary.
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index dbd3197a88..87dedc5b57 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -2044,6 +2044,8 @@ tor_mutex_new(void) void tor_mutex_free(tor_mutex_t *m) { + if (!m) + return; tor_mutex_uninit(m); tor_free(m); } @@ -2071,7 +2073,8 @@ tor_cond_new(void) void tor_cond_free(tor_cond_t *cond) { - tor_assert(cond); + if (!cond) + return; if (pthread_cond_destroy(&cond->cond)) { log_warn(LD_GENERAL,"Error freeing condition: %s", strerror(errno)); return; @@ -2128,7 +2131,8 @@ tor_cond_new(void) void tor_cond_free(tor_cond_t *cond) { - tor_assert(cond); + if (!cond) + return; DeleteCriticalSection(&cond->mutex); /* XXXX notify? */ smartlist_free(cond->events); |