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.
pull/574/head
Jeffrey Walton 2018-01-22 09:37:04 -05:00
parent aee296d663
commit e1f2b69638
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 1 additions and 59 deletions

View File

@ -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 <class T> counted_ptr<T> & counted_ptr<T>::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 T> 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 && index<this->m_size); return this->m_ptr[index];}
const T& operator[](size_t index) const
{CRYPTOPP_ASSERT(m_size && index<this->m_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; i<this->m_size && i<newSize; i++)
newPtr[i] = m_ptr[i];
delete [] this->m_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<T> &c); // copy not allowed
void operator=(const vector_ptr<T> &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 T> class vector_member_ptrs