summaryrefslogtreecommitdiff
path: root/smartptr.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-01-22 09:37:04 -0500
committerJeffrey Walton <noloader@gmail.com>2018-01-22 09:37:04 -0500
commite1f2b696388655ad898dc40ab23ecf80578f8cf1 (patch)
tree874f8ffecaaf05f3a691d5fd0a47493622d30c50 /smartptr.h
parentaee296d663aa9e0cc365d6adc4c2a7b72b122c5f (diff)
downloadcryptopp-git-e1f2b696388655ad898dc40ab23ecf80578f8cf1.tar.gz
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.
Diffstat (limited to 'smartptr.h')
-rw-r--r--smartptr.h60
1 files changed, 1 insertions, 59 deletions
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
@@ -217,63 +216,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
{
public: