diff --git a/src/memory.cpp b/src/memory.cpp index 873bc754c0..6211687a7a 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -22,9 +22,13 @@ #include "tbb/scalable_allocator.h" #else #include +#if defined(__APPLE__) +#include +#else #include #endif #endif +#endif #if defined(LMP_USER_INTEL) && !defined(LAMMPS_MEMALIGN) && !defined(_WIN32) #define LAMMPS_MEMALIGN 64 @@ -84,7 +88,13 @@ void *Memory::srealloc(void *ptr, bigint nbytes, const char *name) if (offset) { void *optr = ptr; ptr = smalloc(nbytes, name); +#if defined(__APPLE__) + memcpy(ptr, optr, MIN(nbytes,malloc_size(optr))); +#elif defined(_WIN32) || defined(__MINGW32__) + memcpy(ptr, optr, MIN(nbytes,_msize(optr))); +#else memcpy(ptr, optr, MIN(nbytes,malloc_usable_size(optr))); +#endif free(optr); } #else