35 #if defined(_MSC_VER) && (_MSC_VER >= 1400) 37 #define mrpt_alloca(nBytes) _malloca(nBytes) 38 #elif defined(HAVE_ALLOCA) 40 #define mrpt_alloca(nBytes) ::alloca(nBytes) 43 #define mrpt_alloca(nBytes) ::malloc(nBytes) 53 #if defined(_MSC_VER) && (_MSC_VER >= 1400) 55 #define mrpt_alloca_free(mem_block) _freea(mem_block) 56 #elif defined(HAVE_ALLOCA) 58 #define mrpt_alloca_free(mem_block) 61 #define mrpt_alloca_free(mem_block) free(mem_block) 83 if (ptr) ::memset(ptr, 0, bytes);
104 template <
typename _Tp>
107 return (_Tp*)(((size_t)ptr +
n - 1) & -
n);
123 return ((reinterpret_cast<size_t>(ptr)) & 0x7) == 0;
128 return ((reinterpret_cast<size_t>(ptr)) & 0xF) == 0;
134 #define MRPT_MAKE_ALIGNED_OPERATOR_NEW \ 135 void* operator new(size_t size) \ 137 return mrpt::system::os::aligned_malloc(size, 16); \ 139 void* operator new[](size_t size) \ 141 return mrpt::system::os::aligned_malloc(size, 16); \ 143 void operator delete(void* ptr) noexcept \ 145 mrpt::system::os::aligned_free(ptr); \ 147 void operator delete[](void* ptr) noexcept \ 149 mrpt::system::os::aligned_free(ptr); \ 154 static void* operator new(size_t size, void* ptr) \ 156 return ::operator new(size, ptr); \ 158 void operator delete(void* memory, void* ptr) noexcept \ 160 return ::operator delete(memory, ptr); \ 163 void* operator new(size_t size, const std::nothrow_t&) noexcept \ 167 return mrpt::system::os::aligned_malloc(size, 16); \ 174 void operator delete(void* ptr, const std::nothrow_t&)noexcept \ 176 mrpt::system::os::aligned_free(ptr); \ bool is_aligned< 8 >(const void *ptr)
bool is_aligned< 16 >(const void *ptr)
void * aligned_realloc(void *old_ptr, size_t bytes, size_t alignment)
Frees a memory block reserved by aligned_malloc.
_Tp * align_ptr(_Tp *ptr, int n=(int) sizeof(_Tp))
Returns a pointer a bit forward in memory so it's aligned for the given boundary size.
void * aligned_calloc(size_t bytes, size_t alignment)
Identical to aligned_malloc, but it zeroes the reserved memory block.
bool is_aligned(const void *ptr)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
unsigned long getMemoryUsage()
Returns the memory occupied by this process, in bytes.
void * aligned_malloc(size_t bytes, size_t alignment)
Returns an aligned memory block.
void aligned_free(void *p)
Frees a memory block reserved by aligned_malloc.