#define FOLLY_ARENA_H_
#include <cassert>
-#include <utility>
#include <limits>
+#include <utility>
#include <boost/intrusive/slist.hpp>
#include "folly/Likely.h"
#include "folly/Malloc.h"
+#include "folly/Memory.h"
namespace folly {
* guaranteed to be rounded up to a multiple of the maximum alignment
* required on your system; the returned value must be also.
*
- * An implementation that uses malloc() / free() is defined below, see
- * SysAlloc / SysArena.
+ * An implementation that uses malloc() / free() is defined below, see SysArena.
*/
template <class Alloc> struct ArenaAllocatorTraits;
template <class Alloc>
size_t sizeLimit_;
};
+template <class Alloc>
+struct IsArenaAllocator<Arena<Alloc>> : std::true_type { };
+
/**
* By default, don't pad the given size.
*/
}
};
-/**
- * Arena-compatible allocator that calls malloc() and free(); see
- * goodMallocSize() in Malloc.h for goodSize().
- */
-class SysAlloc {
- public:
- void* allocate(size_t size) {
- return checkedMalloc(size);
- }
-
- void deallocate(void* p) {
- free(p);
- }
-};
-
template <>
struct ArenaAllocatorTraits<SysAlloc> {
static size_t goodSize(const SysAlloc& alloc, size_t size) {
*/
class SysArena : public Arena<SysAlloc> {
public:
- explicit SysArena(
- size_t minBlockSize = kDefaultMinBlockSize,
- size_t sizeLimit = 0)
- : Arena<SysAlloc>(SysAlloc(), minBlockSize, sizeLimit) {
+ explicit SysArena(size_t minBlockSize = kDefaultMinBlockSize,
+ size_t sizeLimit = 0)
+ : Arena<SysAlloc>(SysAlloc(), minBlockSize, sizeLimit) {
}
};
+template <>
+struct IsArenaAllocator<SysArena> : std::true_type { };
+
} // namespace folly
#include "folly/Arena-inl.h"