diff options
Diffstat (limited to 'storage/ndb/src/kernel/vm/CArray.hpp')
-rw-r--r-- | storage/ndb/src/kernel/vm/CArray.hpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/storage/ndb/src/kernel/vm/CArray.hpp b/storage/ndb/src/kernel/vm/CArray.hpp index a6e84e2c041..93f75056b50 100644 --- a/storage/ndb/src/kernel/vm/CArray.hpp +++ b/storage/ndb/src/kernel/vm/CArray.hpp @@ -17,6 +17,8 @@ #ifndef CARRAY_HPP #define CARRAY_HPP +#include "ndbd_malloc.hpp" + /** * Template class used for implementing an c - array */ @@ -31,7 +33,7 @@ public: * * Note, can currently only be called once */ - bool setSize(Uint32 noOfElements); + bool setSize(Uint32 noOfElements, bool exit_on_error = true); /** * Get size @@ -69,7 +71,7 @@ template <class T> inline CArray<T>::~CArray(){ if(theArray != 0){ - NdbMem_Free(theArray); + ndbd_free(theArray, size * sizeof(T)); theArray = 0; } } @@ -82,13 +84,19 @@ CArray<T>::~CArray(){ template <class T> inline bool -CArray<T>::setSize(Uint32 noOfElements){ +CArray<T>::setSize(Uint32 noOfElements, bool exit_on_error){ if(size == noOfElements) return true; - theArray = (T *)NdbMem_Allocate(noOfElements * sizeof(T)); + theArray = (T *)ndbd_malloc(noOfElements * sizeof(T)); if(theArray == 0) - return false; + { + if (!exit_on_error) + return false; + ErrorReporter::handleAssert("CArray<T>::setSize malloc failed", + __FILE__, __LINE__, NDBD_EXIT_MEMALLOC); + return false; // not reached + } size = noOfElements; return true; } |