diff --git a/src/ds/dllist.h b/src/ds/dllist.h index 915ce1b..ce40102 100644 --- a/src/ds/dllist.h +++ b/src/ds/dllist.h @@ -1,5 +1,7 @@ #pragma once +#include "helpers.h" + #include #include @@ -55,7 +57,7 @@ namespace snmalloc template< class T, class Terminator = std::nullptr_t, - bool delete_on_clear = false> + void on_clear(T*) = ignore> class DLList final { private: @@ -196,10 +198,7 @@ namespace snmalloc { auto c = head; remove(c); - if (delete_on_clear) - { - delete c; - } + on_clear(c); } } diff --git a/src/ds/helpers.h b/src/ds/helpers.h index 159db49..54e2322 100644 --- a/src/ds/helpers.h +++ b/src/ds/helpers.h @@ -142,4 +142,10 @@ namespace snmalloc return (*static_cast>(p))(args...); }; }; + + template + void ignore(T* t) + { + UNUSED(t); + } } // namespace snmalloc