Commit 090b0ac7 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Make SysBufferDeleter::operator() inlineable

Summary: [Folly] Make `SysBufferDeleter::operator()` inlineable, specifically, into `SysBufferUniquePtr`.

Reviewed By: luciang

Differential Revision: D6182999

fbshipit-source-id: e0409c0019f21ed44d7d4c531ebc11a239f25831
parent 8034b69f
...@@ -137,18 +137,12 @@ std::weak_ptr<T> to_weak_ptr(const std::shared_ptr<T>& ptr) { ...@@ -137,18 +137,12 @@ std::weak_ptr<T> to_weak_ptr(const std::shared_ptr<T>& ptr) {
return std::weak_ptr<T>(ptr); return std::weak_ptr<T>(ptr);
} }
namespace detail { struct SysBufferDeleter {
/** void operator()(void* p) const {
* Not all STL implementations define ::free in a way that its address can be ::free(p);
* determined at compile time. So we must wrap ::free in a function whose }
* address can be determined. };
*/
inline void SysFree(void* p) {
::free(p);
}
} // namespace detail
using SysBufferDeleter = static_function_deleter<void, &detail::SysFree>;
using SysBufferUniquePtr = std::unique_ptr<void, SysBufferDeleter>; using SysBufferUniquePtr = std::unique_ptr<void, SysBufferDeleter>;
inline SysBufferUniquePtr allocate_sys_buffer(size_t size) { inline SysBufferUniquePtr allocate_sys_buffer(size_t size) {
return SysBufferUniquePtr(::malloc(size)); return SysBufferUniquePtr(::malloc(size));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment