summaryrefslogtreecommitdiff
path: root/secblock.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-05-04 15:24:09 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-05-04 15:24:09 +0000
commitdf1ffe1e41f89222c379d982e543c2a32da78cbd (patch)
tree3ddcd92ac078642dfed5375980dc2db4006d1498 /secblock.h
parent1bb93ea95e3131c2b9a4f8f8bd3f3197e4d52a76 (diff)
downloadcryptopp-df1ffe1e41f89222c379d982e543c2a32da78cbd.tar.gz
fix compile for x64, DLL and VC 6
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@332 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'secblock.h')
-rw-r--r--secblock.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/secblock.h b/secblock.h
index cdc67c1..0bc5324 100644
--- a/secblock.h
+++ b/secblock.h
@@ -130,10 +130,13 @@ public:
#endif
assert(IsAlignedOn(p, 16));
- return (T*)p;
+ return (pointer)p;
}
- return new T[n];
+ pointer p;
+ while (!(p = (pointer)malloc(sizeof(T)*n)))
+ CallNewHandler();
+ return p;
}
void deallocate(void *p, size_type n)
@@ -153,7 +156,7 @@ public:
return;
}
- delete [] (T *)p;
+ free(p);
}
pointer reallocate(T *p, size_type oldSize, size_type newSize, bool preserve)
@@ -164,13 +167,19 @@ public:
// VS.NET STL enforces the policy of "All STL-compliant allocators have to provide a
// template class member called rebind".
template <class U> struct rebind { typedef AllocatorWithCleanup<U, T_Align16> other; };
+#if _MSC_VER >= 1500
+ AllocatorWithCleanup() {}
+ template <class U, bool A> AllocatorWithCleanup(const AllocatorWithCleanup<U, A> &) {}
+#endif
};
CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<byte>;
CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word16>;
CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word32>;
CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word64>;
-CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word, CRYPTOPP_BOOL_X86>; // for Integer
+#if CRYPTOPP_BOOL_X86
+CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup<word, true>; // for Integer
+#endif
template <class T>
class NullAllocator : public AllocatorBase<T>
@@ -260,7 +269,7 @@ public:
size_type max_size() const {return STDMAX(m_fallbackAllocator.max_size(), S);}
private:
- T* GetAlignedArray() {return T_Align16 ? (T*)(((byte *)m_array) + (0-(unsigned int)m_array)%16) : m_array;}
+ T* GetAlignedArray() {return T_Align16 ? (T*)(((byte *)m_array) + (0-(size_t)m_array)%16) : m_array;}
CRYPTOPP_ALIGN_DATA(8) T m_array[T_Align16 ? S+8/sizeof(T) : S];
A m_fallbackAllocator;
@@ -466,10 +475,10 @@ public:
explicit SecBlockWithHint(size_t size) : SecBlock<T, A>(size) {}
};
-template<class T, class U>
-inline bool operator==(const CryptoPP::AllocatorWithCleanup<T>&, const CryptoPP::AllocatorWithCleanup<U>&) {return (true);}
-template<class T, class U>
-inline bool operator!=(const CryptoPP::AllocatorWithCleanup<T>&, const CryptoPP::AllocatorWithCleanup<U>&) {return (false);}
+template<class T, bool A, class U, bool B>
+inline bool operator==(const CryptoPP::AllocatorWithCleanup<T, A>&, const CryptoPP::AllocatorWithCleanup<U, B>&) {return (true);}
+template<class T, bool A, class U, bool B>
+inline bool operator!=(const CryptoPP::AllocatorWithCleanup<T, A>&, const CryptoPP::AllocatorWithCleanup<U, B>&) {return (false);}
NAMESPACE_END