enable and apply clang-format

This commit is contained in:
Axel Kohlmeyer
2025-04-05 15:48:10 -04:00
parent 0bfa5b210b
commit 3fc0868db9

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -62,7 +61,7 @@ void *Memory::smalloc(bigint nbytes, const char *name)
void *ptr = malloc(nbytes);
#endif
if (ptr == nullptr)
error->one(FLERR,"Failed to allocate {} bytes for array {}", nbytes,name);
error->one(FLERR, Error::NOLASTLINE, "Failed to allocate {} bytes for array {}", nbytes, name);
return ptr;
}
@ -80,28 +79,28 @@ void *Memory::srealloc(void *ptr, bigint nbytes, const char *name)
#if defined(LMP_USE_TBB_ALLOCATOR)
ptr = scalable_aligned_realloc(ptr, nbytes, LAMMPS_MEMALIGN);
#elif defined(LMP_INTEL_NO_TBB) && defined(LAMMPS_MEMALIGN) && \
(defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER))
(defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER))
ptr = realloc(ptr, nbytes);
uintptr_t offset = ((uintptr_t)(const void *)(ptr)) % LAMMPS_MEMALIGN;
uintptr_t offset = ((uintptr_t) (const void *) (ptr)) % LAMMPS_MEMALIGN;
if (offset) {
void *optr = ptr;
ptr = smalloc(nbytes, name);
#if defined(__APPLE__)
memcpy(ptr, optr, MIN(nbytes,malloc_size(optr)));
memcpy(ptr, optr, MIN(nbytes, malloc_size(optr)));
#elif defined(_WIN32) || defined(__MINGW32__)
memcpy(ptr, optr, MIN(nbytes,_msize(optr)));
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);
}
#else
ptr = realloc(ptr,nbytes);
ptr = realloc(ptr, nbytes);
#endif
if (ptr == nullptr)
error->one(FLERR,"Failed to reallocate {} bytes for array {}",
nbytes,name);
error->one(FLERR, Error::NOLASTLINE, "Failed to reallocate {} bytes for array {}", nbytes,
name);
return ptr;
}
@ -112,11 +111,11 @@ void *Memory::srealloc(void *ptr, bigint nbytes, const char *name)
void Memory::sfree(void *ptr)
{
if (ptr == nullptr) return;
#if defined(LMP_USE_TBB_ALLOCATOR)
#if defined(LMP_USE_TBB_ALLOCATOR)
scalable_aligned_free(ptr);
#else
#else
free(ptr);
#endif
#endif
}
/* ----------------------------------------------------------------------
@ -125,5 +124,6 @@ void Memory::sfree(void *ptr)
void Memory::fail(const char *name)
{
error->one(FLERR,"Cannot create/grow a vector/array of pointers for {}",name);
error->one(FLERR, Error::NOLASTLINE, "Cannot create/grow a vector/array of pointers for {}",
name);
}