Fix the system-dependent function call to malloc_usable_size.
Fix the system-dependent function call to get the size of the block of memory allocated from the heap.
This commit is contained in:
@ -22,9 +22,13 @@
|
|||||||
#include "tbb/scalable_allocator.h"
|
#include "tbb/scalable_allocator.h"
|
||||||
#else
|
#else
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <malloc/malloc.h>
|
||||||
|
#else
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(LMP_USER_INTEL) && !defined(LAMMPS_MEMALIGN) && !defined(_WIN32)
|
#if defined(LMP_USER_INTEL) && !defined(LAMMPS_MEMALIGN) && !defined(_WIN32)
|
||||||
#define LAMMPS_MEMALIGN 64
|
#define LAMMPS_MEMALIGN 64
|
||||||
@ -84,7 +88,13 @@ void *Memory::srealloc(void *ptr, bigint nbytes, const char *name)
|
|||||||
if (offset) {
|
if (offset) {
|
||||||
void *optr = ptr;
|
void *optr = ptr;
|
||||||
ptr = smalloc(nbytes, name);
|
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)));
|
memcpy(ptr, optr, MIN(nbytes,malloc_usable_size(optr)));
|
||||||
|
#endif
|
||||||
free(optr);
|
free(optr);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user