summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-13 11:16:28 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-13 11:16:28 +0000
commitb1d5c9a600e07a434b21353afe86374940e95bc8 (patch)
tree7af35b495d4e9fddfff4b173d2a7688ed3b3231c
parent1c7bd8499b4eb0f5d0362661c86d9412f7c1bafc (diff)
downloadcryptopp-b1d5c9a600e07a434b21353afe86374940e95bc8.tar.gz
fix compile on gcc 4.1.2, armv5tel
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@451 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r--algparam.cpp45
-rw-r--r--algparam.h27
2 files changed, 11 insertions, 61 deletions
diff --git a/algparam.cpp b/algparam.cpp
index 89eacfe..a70d5dd 100644
--- a/algparam.cpp
+++ b/algparam.cpp
@@ -46,63 +46,30 @@ bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_inf
}
AlgorithmParameters::AlgorithmParameters()
- : m_constructed(false), m_defaultThrowIfNotUsed(true)
+ : m_defaultThrowIfNotUsed(true)
{
- new(m_first) member_ptr<AlgorithmParametersBase>;
}
AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x)
- : m_constructed(false), m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
+ : m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
{
- if (x.m_constructed)
- {
- x.First().MoveInto(m_first);
- m_constructed = true;
- }
- else
- new(m_first) member_ptr<AlgorithmParametersBase>(x.Next().release());
-}
-
-AlgorithmParameters::~AlgorithmParameters()
-{
- if (m_constructed)
- First().~AlgorithmParametersBase();
- else
- Next().~member_ptr<AlgorithmParametersBase>();
+ m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
}
AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
{
- if (this == &x)
- return *this;
- this->~AlgorithmParameters();
- new (this) AlgorithmParameters(x);
+ m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
return *this;
}
bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
{
- if (m_constructed)
- return First().GetVoidValue(name, valueType, pValue);
- else if (Next().get())
- return Next()->GetVoidValue(name, valueType, pValue);
+ if (m_next.get())
+ return m_next->GetVoidValue(name, valueType, pValue);
else
return false;
}
-AlgorithmParametersBase & AlgorithmParameters::First()
-{
- return *reinterpret_cast<AlgorithmParametersBase *>(m_first);
-}
-
-member_ptr<AlgorithmParametersBase> & AlgorithmParameters::Next()
-{
- if (m_constructed)
- return First().m_next;
- else
- return *reinterpret_cast<member_ptr<AlgorithmParametersBase> *>(m_first);
-}
-
NAMESPACE_END
#endif
diff --git a/algparam.h b/algparam.h
index f87c93d..140f579 100644
--- a/algparam.h
+++ b/algparam.h
@@ -337,26 +337,14 @@ public:
AlgorithmParameters(const AlgorithmParameters &x);
- ~AlgorithmParameters();
-
AlgorithmParameters & operator=(const AlgorithmParameters &x);
template <class T>
AlgorithmParameters & operator()(const char *name, const T &value, bool throwIfNotUsed)
{
- if (m_constructed || sizeof(m_first) < sizeof(AlgorithmParametersTemplate<T>))
- {
- member_ptr<AlgorithmParametersBase> p(new AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed));
- p->m_next.reset(Next().release());
- Next().reset(p.release());
- }
- else
- {
- member_ptr<AlgorithmParametersBase> temp(Next().release());
- AlgorithmParametersTemplate<T>* p = new(m_first) AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed);
- p->m_next.reset(temp.release());
- m_constructed = true;
- }
+ member_ptr<AlgorithmParametersBase> p(new AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed));
+ p->m_next.reset(m_next.release());
+ m_next.reset(p.release());
m_defaultThrowIfNotUsed = throwIfNotUsed;
return *this;
}
@@ -370,13 +358,8 @@ public:
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
protected:
- AlgorithmParametersBase & First();
- member_ptr<AlgorithmParametersBase> & Next();
- const AlgorithmParametersBase & First() const {return const_cast<AlgorithmParameters *>(this)->First();}
- member_ptr<AlgorithmParametersBase> & Next() const {return const_cast<AlgorithmParameters *>(this)->Next();}
-
- bool m_constructed, m_defaultThrowIfNotUsed;
- size_t m_first[(sizeof(AlgorithmParametersBase) + 19)/sizeof(size_t)];
+ member_ptr<AlgorithmParametersBase> m_next;
+ bool m_defaultThrowIfNotUsed;
};
//! Create an object that implements NameValuePairs for passing parameters