biod.pnpi.spb.ru
/
alexxy
/
gromacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move remaining C files in utility to C++
[alexxy/gromacs.git]
/
src
/
gromacs
/
utility
/
smalloc.cpp
diff --git
a/src/gromacs/utility/smalloc.c
b/src/gromacs/utility/smalloc.cpp
similarity index 95%
rename from
src/gromacs/utility/smalloc.c
rename to
src/gromacs/utility/smalloc.cpp
index 876675ecd440ad17f2346181bbed9b69c810e053..ac8fd499b0e6849de70030b19d7e9755ba3feb30 100644
(file)
--- a/
src/gromacs/utility/smalloc.c
+++ b/
src/gromacs/utility/smalloc.cpp
@@
-43,7
+43,6
@@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
@@
-52,6
+51,8
@@
#include <malloc.h>
#endif
#include <malloc.h>
#endif
+#include <cstring>
+
#include "thread_mpi/threads.h"
#include "gromacs/utility/dir_separator.h"
#include "thread_mpi/threads.h"
#include "gromacs/utility/dir_separator.h"
@@
-131,7
+132,7
@@
void *save_malloc(const char *name, const char *file, int line, size_t size)
if ((p = malloc(size)) == NULL)
{
gmx_fatal(errno, __FILE__, __LINE__,
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);
}
"(called from file %s, line %d)",
(gmx_int64_t)size, name, file, line);
}
@@
-169,8
+170,8
@@
void *save_calloc(const char *name, const char *file, int line,
if ((p = malloc((size_t)nelem*(size_t)elsize)) == NULL)
{
gmx_fatal(errno, __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);
" for %s\n(called from file %s, line %d)",
(gmx_int64_t)nelem, (gmx_int64_t)elsize,
name, file, line);
@@
-180,8
+181,8
@@
void *save_calloc(const char *name, const char *file, int line,
if ((p = calloc((size_t)nelem, (size_t)elsize)) == NULL)
{
gmx_fatal(errno, __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);
}
" for %s\n(called from file %s, line %d)",
(gmx_int64_t)nelem, (gmx_int64_t)elsize, name, file, line);
}
@@
-225,7
+226,7
@@
void *save_realloc(const char *name, const char *file, int line, void *ptr,
if (p == NULL)
{
gmx_fatal(errno, __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);
}
"(called from file %s, line %d)",
(gmx_int64_t)size, name, name, ptr, file, line);
}
@@
-343,7
+344,6
@@
void *save_calloc_aligned(const char *name, const char *file, int 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)
{
/* 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)
void *free = ptr;
if (NULL != ptr)
@@
-375,7
+375,7
@@
int over_alloc_dd(int n)
{
if (g_bOverAllocDD)
{
{
if (g_bOverAllocDD)
{
- return
OVER_ALLOC_FAC*n + 100
;
+ return
static_cast<int>(OVER_ALLOC_FAC*n + 100)
;
}
else
{
}
else
{