diff options
Diffstat (limited to 'include/fwd/sptree.h')
-rw-r--r-- | include/fwd/sptree.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/fwd/sptree.h b/include/fwd/sptree.h index 75b88fc..e305c0f 100644 --- a/include/fwd/sptree.h +++ b/include/fwd/sptree.h @@ -400,12 +400,18 @@ static inline void SPTREE(remove)(struct SPROOT *s, SPTREE_TYPE data) return; SPTREE(remove_found)(s, found); + struct SPNODE *del = CONTAINER_OF(found, struct SPNODE, data); + free(del); } static inline void SPTREE(destroy)(struct SPROOT *s) { - while (s->root) - SPTREE(remove_found)(s, &s->root->data); + while (s->root) { + SPTREE_TYPE *top = &s->root->data; + SPTREE(remove_found)(s, top); + struct SPNODE *del = CONTAINER_OF(top, struct SPNODE, data); + free(del); + } } #undef SPTREE |