Commit 3c4e5184 authored by Jan Včelák's avatar Jan Včelák 🚀

heap: add deinit function

parent b07dd6e0
......@@ -59,6 +59,12 @@ int heap_init(struct heap *h, int (*cmp)(void *, void *), int init_size)
return h->data ? 1 : 0;
}
void heap_deinit(struct heap *h)
{
free(h->data);
memset(h, 0, sizeof(*h));
}
static inline void _heap_bubble_down(struct heap *h, int e)
{
int e1;
......
......@@ -37,6 +37,8 @@ struct heap {
#define EMPTY_HEAP(h) ((h)->num == 0) /* h->num == 0 */
int heap_init(struct heap *, int (*cmp)(), int);
void heap_deinit(struct heap *);
void heap_delmin(struct heap *);
int heap_insert(struct heap *, heap_val_t *);
int heap_find(struct heap *, heap_val_t *);
......
......@@ -137,7 +137,7 @@ void evsched_deinit(evsched_t *sched)
evsched_event_free(e);
}
free(sched->heap.data);
heap_deinit(&sched->heap);
if (sched->thread != NULL) {
dt_delete(&sched->thread);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment