41 template <
typename Data>
42 static void allocate(Data*& ptr,
size_t size);
52 template <
typename Data>
53 static void deallocate(Data*& ptr,
size_t size);
69 template <
typename Data>
70 static void reallocate(Data*& ptr,
size_t oldSize,
size_t newSize);
104 static int max(MPI::Intracomm& communicator);
121 static int nAllocate_;
124 static int nDeallocate_;
131 template <
typename Data>
135 UTIL_THROW(
"Attempt to allocate to non-null pointer");
138 ptr =
new Data[size];
139 total_ += (size*
sizeof(Data));
141 if (total_ > max_) max_ = total_;
142 }
catch (std::bad_alloc&) {
143 std::cout <<
"Allocation error" << std::endl;
151 template <
typename Data>
160 total_ -= size*
sizeof(Data);
167 template <
typename Data>
177 for (
size_t i = 0; i < oldSize; ++i) {
Provides method to allocate array.
static void deallocate(Data *&ptr, size_t size)
Deallocate a C++ array.
static int max()
Return the maximum amount of allocated heap memory thus far.
static int nAllocate()
Return number of times allocate() was called.
static void reallocate(Data *&ptr, size_t oldSize, size_t newSize)
Reallocate a C++ array.
static void initStatic()
Call this just to guarantee initialization of static memory.
static int total()
Return total amount of memory currently allocated.
static void allocate(Data *&ptr, size_t size)
Allocate a C++ array.
static int nDeallocate()
Return number of times deallocate() was called.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.