From 090b0ac74a96e4f3acca6c45cbc747eece365679 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Sun, 29 Oct 2017 03:33:15 -0700 Subject: [PATCH] Make SysBufferDeleter::operator() inlineable Summary: [Folly] Make `SysBufferDeleter::operator()` inlineable, specifically, into `SysBufferUniquePtr`. Reviewed By: luciang Differential Revision: D6182999 fbshipit-source-id: e0409c0019f21ed44d7d4c531ebc11a239f25831 --- folly/Memory.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/folly/Memory.h b/folly/Memory.h index c6c3ea21..446d8896 100644 --- a/folly/Memory.h +++ b/folly/Memory.h @@ -137,18 +137,12 @@ std::weak_ptr to_weak_ptr(const std::shared_ptr& ptr) { return std::weak_ptr(ptr); } -namespace detail { -/** - * Not all STL implementations define ::free in a way that its address can be - * 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 +struct SysBufferDeleter { + void operator()(void* p) const { + ::free(p); + } +}; -using SysBufferDeleter = static_function_deleter; using SysBufferUniquePtr = std::unique_ptr; inline SysBufferUniquePtr allocate_sys_buffer(size_t size) { return SysBufferUniquePtr(::malloc(size)); -- 2.34.1