+ DestroyPointer(const_cast<T *>(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external
+ _pointer.setInternal(pointer);
+ _nb_of_elem=std::min<std::size_t>(_nb_of_elem,newNbOfElements);
+ _nb_of_elem_alloc=newNbOfElements;
+ _ownership=true;
+ _dealloc=CDeallocator;
+ _param_for_deallocator=0;
+ }
+
+ /*!
+ * This method performs systematically an allocation of \a newNbOfElements elements in \a this.
+ * \a _nb_of_elem and \a _nb_of_elem_alloc will be equal even if only std::min<std::size_t>(_nb_of_elem,newNbOfElements) come from the .
+ * The remaing part of the new allocated chunk are available but not set previouly !
+ *
+ * So this method should not be confused with MemArray<T>::reserve that is close to MemArray<T>::reAlloc but not same.
+ */
+ template<class T>
+ void MemArray<T>::reAlloc(std::size_t newNbOfElements)
+ {
+ if(_nb_of_elem==newNbOfElements)
+ return ;
+ T *pointer=(T*)malloc(newNbOfElements*sizeof(T));
+ std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<std::size_t>(_nb_of_elem,newNbOfElements),pointer);
+ if(_ownership)
+ DestroyPointer(const_cast<T *>(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external