mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-22 09:31:10 +00:00
Use reference type for deleter
This commit is contained in:
parent
c5d3f07b84
commit
80fb932ec3
@ -11,7 +11,7 @@ template <class T> class Allocator
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Allocator() : deleter([this](T *p) { this->release(p); }) {}
|
Allocator() : deleter(std::bind(&Allocator::release, this, std::placeholders::_1)) {}
|
||||||
virtual ~Allocator() {}
|
virtual ~Allocator() {}
|
||||||
|
|
||||||
/// Return a queable object which has been prefilled with zeros. Panic if no buffer is available
|
/// Return a queable object which has been prefilled with zeros. Panic if no buffer is available
|
||||||
@ -47,7 +47,7 @@ template <class T> class Allocator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Variations of the above methods that return std::unique_ptr instead of raw pointers.
|
/// Variations of the above methods that return std::unique_ptr instead of raw pointers.
|
||||||
using UniqueAllocation = std::unique_ptr<T, std::function<void(T *)>>;
|
using UniqueAllocation = std::unique_ptr<T, const std::function<void(T *)> &>;
|
||||||
/// Return a queable object which has been prefilled with zeros.
|
/// Return a queable object which has been prefilled with zeros.
|
||||||
/// std::unique_ptr wrapped variant of allocZeroed().
|
/// std::unique_ptr wrapped variant of allocZeroed().
|
||||||
UniqueAllocation allocUniqueZeroed() { return UniqueAllocation(allocZeroed(), deleter); }
|
UniqueAllocation allocUniqueZeroed() { return UniqueAllocation(allocZeroed(), deleter); }
|
||||||
|
Loading…
Reference in New Issue
Block a user