CoMD
A Mini-app for Co-Design of Classical Molecular Dynamics.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
memUtils.h
Go to the documentation of this file.
1 /// \file
2 /// Wrappers for memory allocation.
3 
4 #ifndef _MEMUTILS_H_
5 #define _MEMUTILS_H_
6 
7 #include <stdlib.h>
8 
9 #define freeMe(s,element) {if(s->element) comdFree(s->element); s->element = NULL;}
10 
11 static void* comdMalloc(size_t iSize)
12 {
13  return malloc(iSize);
14 }
15 
16 static void* comdCalloc(size_t num, size_t iSize)
17 {
18  return calloc(num, iSize);
19 }
20 
21 static void* comdRealloc(void* ptr, size_t iSize)
22 {
23  return realloc(ptr, iSize);
24 }
25 
26 static void comdFree(void *ptr)
27 {
28  free(ptr);
29 }
30 #endif