37 #define MEMORY_ALIGN(pos,size) ((((pos) + (size) - 1) / (size)) * (size))
42 #if defined(ENABLE_MEMCHECK)
43 #define MEMORY_CANARY_SIZE 16
44 #define MEMORY_CANARY_FIRST_BYTE 0xca
45 #define MEMORY_CLEAR_BYTE 0xa5
89 #define PADDING(pos,size) (MEMORY_ALIGN((pos),(size)) - (pos))
90 #define OFFSET(s,el) ((int32_t) ((ptrint) &(((s*) 0)->el)))
93 #define NEW(type) ((type *) mem_alloc(sizeof(type)))
94 #define FREE(ptr,type) mem_free((ptr), sizeof(type))
96 #define MNEW(type,num) ((type *) mem_alloc(sizeof(type) * (num)))
97 #define MFREE(ptr,type,num) mem_free((ptr), sizeof(type) * (num))
99 #define MREALLOC(ptr,type,num1,num2) mem_realloc((ptr), sizeof(type) * (num1), \
100 sizeof(type) * (num2))
103 #define MCOPY(dest,src,type,num) std::memcpy((dest), (src), sizeof(type) * (num))
104 #define MSET(ptr,byte,type,num) std::memset((ptr), (byte), sizeof(type) * (num))
105 #define MZERO(ptr,type,num) MSET(ptr,0,type,num)
106 #define MMOVE(dest,src,type,num) std::memmove((dest), (src), sizeof(type) * (num))
111 #if defined(ENABLE_GC_BOEHM)
115 #define GCNEW_UNCOLLECTABLE(type,num) ((type *) heap_alloc_uncollectable(sizeof(type) * (num)))
117 #define GCNEW(type) heap_alloc(sizeof(type), true, NULL, true)
118 #define GCMNEW(type,num) heap_alloc(sizeof(type) * (num), true, NULL, true)
120 #define GCFREE(ptr) heap_free((ptr))
138 void *
mem_realloc(
void *src, int32_t len1, int32_t len2);
190 new ((
void*) p) T(value);
206 #endif // MEMORY_HPP_
pointer reallocate(pointer p, size_type old_sz, size_type new_sz)
MemoryAllocator(const MemoryAllocator &)
const_pointer address(const_reference x) const
void memory_cfree(void *p, int32_t size)
const T & const_reference
MemoryAllocator(const MemoryAllocator< U > &)
JNIEnv jthread jobject jclass jlong size
void memory_mprotect(void *addr, size_t len, int prot)
void deallocate(pointer p, size_type n)
void * memory_checked_alloc(size_t size)
void mem_free(void *m, int32_t size)
void construct(pointer p, const T &value)
void * mem_realloc(void *src, int32_t len1, int32_t len2)
std::ptrdiff_t difference_type
pointer address(reference x) const
bool memory_start_thread(void)
pointer allocate(size_type n, const_pointer hint=0)
void * mem_alloc(int32_t size)
void * memory_cnew(int32_t size)
MemAllocPlacement
Allow operator new to allocate with mem_alloc.