Clean up qd_link_ref_t objects associated with the link before freeing it
@@ -880,6 +880,19 @@ void qd_link_free(qd_link_t *link)
sys_mutex_lock(container->lock);
DEQ_REMOVE(container->links, link);
sys_mutex_unlock(container->lock);
+
+
+ qd_link_ref_list_t *list = qd_link_get_ref_list(link);
+
+ if (list) {
+ qd_link_ref_t *link_ref = DEQ_HEAD (*list);
+ while (link_ref) {
+ DEQ_REMOVE_HEAD(*list);
+ free_qd_link_ref_t(link_ref);
+ link_ref = DEQ_HEAD (*list);
+ }
+ }
+
free_qd_link_t(link);
}
