Fix for Mac OS X 10.14
The dllist was able to call delete during a destructor if a template flag was set. This flag is never set in snmalloc, and was included to enable reuse in another project. This was triggering an error on older mac builds. This PR calls a templated function when the DLList is destructed. Hence other projects can specify the `delete` behaviour if required.
This commit is contained in:
committed by
Matthew Parkinson
parent
35346e72c3
commit
1d12e34b9f
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -55,7 +57,7 @@ namespace snmalloc
|
||||
template<
|
||||
class T,
|
||||
class Terminator = std::nullptr_t,
|
||||
bool delete_on_clear = false>
|
||||
void on_clear(T*) = ignore<T>>
|
||||
class DLList final
|
||||
{
|
||||
private:
|
||||
@@ -196,10 +198,7 @@ namespace snmalloc
|
||||
{
|
||||
auto c = head;
|
||||
remove(c);
|
||||
if (delete_on_clear)
|
||||
{
|
||||
delete c;
|
||||
}
|
||||
on_clear(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,4 +142,10 @@ namespace snmalloc
|
||||
return (*static_cast<std::add_pointer_t<Fn>>(p))(args...);
|
||||
};
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void ignore(T* t)
|
||||
{
|
||||
UNUSED(t);
|
||||
}
|
||||
} // namespace snmalloc
|
||||
|
||||
Reference in New Issue
Block a user