summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Vavrusa <marek.vavrusa@nic.cz>2013-05-29 15:16:27 +0200
committerGerrit Code Review <gerrit@git>2013-05-29 17:36:31 +0200
commitf4ce7a931a72bfe04064f812773a6d94160a5fba (patch)
tree97cb2f27aaaaa5ea3499bfaaf8004b26eede2b87
parentModernize autotools usage and split unittests into separate TESTS target (diff)
downloadknot-f4ce7a931a72bfe04064f812773a6d94160a5fba.tar.xz
knot-f4ce7a931a72bfe04064f812773a6d94160a5fba.zip
Free all event nodes at once on exit.
Change-Id: I12e5a43c71243b0774d049b25973d34ae41b6078
-rw-r--r--src/common/evsched.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/common/evsched.c b/src/common/evsched.c
index 7df2e0ce8..5061fe670 100644
--- a/src/common/evsched.c
+++ b/src/common/evsched.c
@@ -100,20 +100,21 @@ void evsched_delete(evsched_t **s)
pthread_mutex_destroy(&(*s)->mx);
pthread_cond_destroy(&(*s)->notify);
- while (! EMPTY_HEAP(&(*s)->heap)) /* FIXME: Would be faster to simply walk through the array */
+#ifndef OPENBSD_SLAB_BROKEN
+ /* Free allocator (all events at once). */
+ slab_cache_destroy(&(*s)->cache.alloc);
+#else
+ while (! EMPTY_HEAP(&(*s)->heap))
{
event_t *e = *((event_t**)(HHEAD(&(*s)->heap)));
heap_delmin(&(*s)->heap);
evsched_event_free((*s), e);
}
+#endif
free((*s)->heap.data);
(*s)->heap.data = NULL;;
-#ifndef OPENBSD_SLAB_BROKEN
- /* Free allocator. */
- slab_cache_destroy(&(*s)->cache.alloc);
-#endif
pthread_mutex_destroy(&(*s)->cache.lock);
/* Free scheduler. */