From 74928f27a46fe679caf84a09bd00f03dd36e3f9f Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Wed, 19 Dec 2018 11:50:33 -0600 Subject: [PATCH] Corrected destructor loop to clear all pending events In `equeue_destroy` the external loop was for main events linked list and internal loop for siblings. Siblings start was not initialized correctly for each main link --- equeue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/equeue.c b/equeue.c index 9da33e0..ad4e47d 100644 --- a/equeue.c +++ b/equeue.c @@ -91,13 +91,15 @@ int equeue_create_inplace(equeue_t *q, size_t size, void *buffer) { void equeue_destroy(equeue_t *q) { // call destructors on pending events for (struct equeue_event *es = q->queue; es; es = es->next) { - for (struct equeue_event *e = q->queue; e; e = e->sibling) { + for (struct equeue_event *e = es->sibling; e; e = e->sibling) { if (e->dtor) { e->dtor(e + 1); } } + if (es->dtor) { + es->dtor(es + 1); + } } - // notify background timer if (q->background.update) { q->background.update(q->background.timer, -1);