Unverified Commit 438346a9 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #2237 from yafshar/memory

Fix the system-dependent function call to `malloc_usable_size`.
parents dff2e93e 508a38a7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -22,9 +22,13 @@
#include "tbb/scalable_allocator.h"
#else
#include <cstring>
#if defined(__APPLE__)
#include <malloc/malloc.h>
#else
#include <malloc.h>
#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