/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2012,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2012,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
int t, v;
size_t s, st;
+ if (size == 0)
+ {
+ return;
+ }
+
cbase = (char *)base;
swaptype = (size_t)(cbase - (char *)0) % sizeof(int) || size % sizeof(int) ? 2 : size == sizeof(int) ? 0 : 1;
}
else
{
- pv = (char*)(void*)&v;
v = *(int *)pm;
+ pv = (char*)(void*)&v;
}
pa = pb = cbase;
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#include <malloc.h>
#endif
+#include <cstring>
+
#include "thread_mpi/threads.h"
#include "gromacs/utility/dir_separator.h"
if ((p = malloc(size)) == NULL)
{
gmx_fatal(errno, __FILE__, __LINE__,
- "Not enough memory. Failed to malloc %"GMX_PRId64 " bytes for %s\n"
+ "Not enough memory. Failed to malloc %" GMX_PRId64 " bytes for %s\n"
"(called from file %s, line %d)",
(gmx_int64_t)size, name, file, line);
}
if ((p = malloc((size_t)nelem*(size_t)elsize)) == NULL)
{
gmx_fatal(errno, __FILE__, __LINE__,
- "Not enough memory. Failed to calloc %"GMX_PRId64
- " elements of size %"GMX_PRId64
+ "Not enough memory. Failed to calloc %" GMX_PRId64
+ " elements of size %" GMX_PRId64
" for %s\n(called from file %s, line %d)",
(gmx_int64_t)nelem, (gmx_int64_t)elsize,
name, file, line);
if ((p = calloc((size_t)nelem, (size_t)elsize)) == NULL)
{
gmx_fatal(errno, __FILE__, __LINE__,
- "Not enough memory. Failed to calloc %"GMX_PRId64
- " elements of size %"GMX_PRId64
+ "Not enough memory. Failed to calloc %" GMX_PRId64
+ " elements of size %" GMX_PRId64
" for %s\n(called from file %s, line %d)",
(gmx_int64_t)nelem, (gmx_int64_t)elsize, name, file, line);
}
if (p == NULL)
{
gmx_fatal(errno, __FILE__, __LINE__,
- "Not enough memory. Failed to realloc %"GMX_PRId64 " bytes for %s, %s=%x\n"
+ "Not enough memory. Failed to realloc %" GMX_PRId64 " bytes for %s, %s=%x\n"
"(called from file %s, line %d)",
(gmx_int64_t)size, name, name, ptr, file, line);
}
/* This routine can NOT be called with any pointer */
void save_free_aligned(const char gmx_unused *name, const char gmx_unused *file, int gmx_unused line, void *ptr)
{
- int i, j;
void *free = ptr;
if (NULL != ptr)
{
if (g_bOverAllocDD)
{
- return OVER_ALLOC_FAC*n + 100;
+ return static_cast<int>(OVER_ALLOC_FAC*n + 100);
}
else
{