From e1f2b696388655ad898dc40ab23ecf80578f8cf1 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 22 Jan 2018 09:37:04 -0500 Subject: Removed vector_ptr vector_ptr was added at Crypto++ 5.6.5 to manage an array acquired with new[] in C++03. We can now use a combination of SecBlock and SetMark(0) to achieve the same effect. --- smartptr.h | 60 +----------------------------------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) (limited to 'smartptr.h') diff --git a/smartptr.h b/smartptr.h index 783e2503..0e330631 100644 --- a/smartptr.h +++ b/smartptr.h @@ -1,7 +1,6 @@ // smartptr.h - originally written and placed in the public domain by Wei Dai -/// \file -/// \headerfile smartptr.h +/// \file smartptr.h /// \brief Classes for automatic resource management #ifndef CRYPTOPP_SMARTPTR_H @@ -215,63 +214,6 @@ template counted_ptr & counted_ptr::operator=(const counted_ptr< // ******************************************************** -/// \brief Manages resources for an array of objects -/// \tparam T class or type -/// \details \p vector_ptr is used frequently in the library to avoid large stack allocations, -/// and manage resources and ensure cleanup under the RAII pattern (Resource Acquisition -/// Is Initialization). -template class vector_ptr -{ -public: - /// Construct an arry of \p T - /// \param size the size of the array, in elements - /// \details If \p T is a Plain Old Dataype (POD), then the array is uninitialized. - vector_ptr(size_t size=0) - : m_size(size), m_ptr(new T[m_size]) {} - ~vector_ptr() - {delete [] m_ptr;} - - T& operator[](size_t index) - {CRYPTOPP_ASSERT(m_size && indexm_size); return this->m_ptr[index];} - const T& operator[](size_t index) const - {CRYPTOPP_ASSERT(m_size && indexm_size); return this->m_ptr[index];} - - size_t size() const {return this->m_size;} - void resize(size_t newSize) - { - T *newPtr = new T[newSize]; - for (size_t i=0; im_size && im_ptr; - this->m_size = newSize; - this->m_ptr = newPtr; - } - -#ifdef __BORLANDC__ - operator T *() const - {return (T*)m_ptr;} -#else - operator const void *() const - {return m_ptr;} - operator void *() - {return m_ptr;} - - operator const T *() const - {return m_ptr;} - operator T *() - {return m_ptr;} -#endif - -private: - vector_ptr(const vector_ptr &c); // copy not allowed - void operator=(const vector_ptr &x); // assignment not allowed - - size_t m_size; - T *m_ptr; -}; - -// ******************************************************** - /// \brief Manages resources for an array of objects /// \tparam T class or type template class vector_member_ptrs -- cgit v1.2.1