summaryrefslogtreecommitdiff
path: root/src/common/container.c
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2009-09-28 16:37:01 +0200
committerSebastian Hahn <sebastian@torproject.org>2009-12-12 03:29:44 +0100
commit3807db001d71c51e53c1897ae067671f5b771f2f (patch)
tree6c6f648f072d24e7bbf554de12519b27cd9ef888 /src/common/container.c
parent4afdb79051f7b1caba49877fb57be60bda9d4514 (diff)
downloadtor-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/container.c')
-rw-r--r--src/common/container.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/common/container.c b/src/common/container.c
index f3540f74d8..7690b4c0ba 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -44,7 +44,8 @@ smartlist_create(void)
void
smartlist_free(smartlist_t *sl)
{
- tor_assert(sl != NULL);
+ if (!sl)
+ return;
tor_free(sl->list);
tor_free(sl);
}
@@ -1187,6 +1188,9 @@ void
strmap_free(strmap_t *map, void (*free_val)(void*))
{
strmap_entry_t **ent, **next, *this;
+ if (!map)
+ return;
+
for (ent = HT_START(strmap_impl, &map->head); ent != NULL; ent = next) {
this = *ent;
next = HT_NEXT_RMV(strmap_impl, &map->head, ent);
@@ -1208,6 +1212,8 @@ void
digestmap_free(digestmap_t *map, void (*free_val)(void*))
{
digestmap_entry_t **ent, **next, *this;
+ if (!map)
+ return;
for (ent = HT_START(digestmap_impl, &map->head); ent != NULL; ent = next) {
this = *ent;
next = HT_NEXT_RMV(digestmap_impl, &map->head, ent);
@@ -1323,6 +1329,8 @@ digestset_new(int max_elements)
void
digestset_free(digestset_t *set)
{
+ if (!set)
+ return;
bitarray_free(set->ba);
tor_free(set);
}