* limitations under the License.
*/
-#ifndef FOLLY_MEMORY_H_
-#define FOLLY_MEMORY_H_
+#pragma once
#include <folly/Traits.h>
#include <folly/portability/Memory.h>
* @author Xu Ning (xning@fb.com)
*/
-#if __cplusplus >= 201402L || \
- defined __cpp_lib_make_unique && __cpp_lib_make_unique >= 201304L
+#if __cplusplus >= 201402L || \
+ (defined __cpp_lib_make_unique && __cpp_lib_make_unique >= 201304L) || \
+ (defined(_MSC_VER) && _MSC_VER >= 1900)
/* using override */ using std::make_unique;
template <typename T, void(*f)(T*)>
struct static_function_deleter {
- void operator()(T* t) { f(t); }
+ void operator()(T* t) const {
+ f(t);
+ }
};
/**
return std::shared_ptr<T>(std::move(ptr));
}
+using SysBufferDeleter = static_function_deleter<void, ::free>;
+using SysBufferUniquePtr = std::unique_ptr<void, SysBufferDeleter>;
+inline SysBufferUniquePtr allocate_sys_buffer(size_t size) {
+ return SysBufferUniquePtr(::malloc(size));
+}
+
/**
* A SimpleAllocator must provide two methods:
*
template <class T> struct IsArenaAllocator : std::false_type { };
} // namespace folly
-
-#endif /* FOLLY_MEMORY_H_ */