22#ifndef MEMORYALLOCATION_H
23#define MEMORYALLOCATION_H
33#include "jemalloc/jemalloc.h"
36#if defined(DEBUG_VLASIATOR) || defined(DEBUG_SPATIAL_CELL)
37#ifndef INITIALIZE_ALIGNED_MALLOC_WITH_NAN
38#define INITIALIZE_ALIGNED_MALLOC_WITH_NAN
58 void *p = je_malloc(size + align - 1 +
sizeof(
void*));
60 void *p = malloc(size + align - 1 +
sizeof(
void*));
62#ifdef INITIALIZE_ALIGNED_MALLOC_WITH_NAN
63 memset(p, ~0u, size + align - 1 +
sizeof(
void*));
68 ptr = (
void*) (((
unsigned long)p +
sizeof(
void*) + align -1) & ~(align-1));
74 *((
void**)((
unsigned long)ptr -
sizeof(
void*))) = p;
87 void *ptr = *((
void**)((
unsigned long)p -
sizeof(
void*)));
108template <
typename T, std::
size_t Alignment>
136 return (
static_cast<std::size_t
>(0) -
static_cast<std::size_t
>(1)) /
sizeof(T);
141 template <
typename U>
149 return !(*
this == other);
154 void *
const pv =
static_cast<void *
>(p);
202 throw std::length_error(
"aligned_allocator<T>::allocate() - Integer overflow.");
211 throw std::bad_alloc();
214 return static_cast<T *
>(pv);
224 template <
typename U>
225 T *
allocate(
const std::size_t n,
const U * )
const
void construct(T *const p, const T &t) const
bool operator==(const aligned_allocator &other) const
aligned_allocator & operator=(const aligned_allocator &)
T * allocate(const std::size_t n) const
T * allocate(const std::size_t n, const U *) const
aligned_allocator(const aligned_allocator &)
const T & const_reference
std::size_t max_size() const
bool operator!=(const aligned_allocator &other) const
aligned_allocator(const aligned_allocator< U, Alignment > &)
ptrdiff_t difference_type
void destroy(T *const p) const
void deallocate(T *const p, const std::size_t) const
const T * address(const T &s) const
void * aligned_malloc(size_t size, std::size_t align)
void memory_configurator()
void aligned_free(void *p)
aligned_allocator< U, Alignment > other