24 #ifndef mySTL_HELPERS_HPP
25 #define mySTL_HELPERS_HPP
39 inline void*
operator new(
size_t size,
Dummy* d)
41 return static_cast<void*
>(d);
45 inline void operator delete(
void* ptr,
Dummy* d)
54 template <
typename T,
typename T2>
55 inline void construct(T* p,
const T2& value)
62 inline void construct(T* p)
69 inline void destroy(T* p)
75 template <
typename Iter>
78 while (first != last) {
85 template <
typename Iter,
typename PlaceIter>
86 PlaceIter uninit_copy(
Iter first,
Iter last, PlaceIter place)
88 while (first != last) {
89 construct(&*place, *first);
97 template <
typename PlaceIter,
typename Size,
typename T>
98 PlaceIter uninit_fill_n(PlaceIter place, Size
n,
const T& value)
101 construct(&*place, value);
109 template <
typename T>
110 T* GetArrayMemory(
size_t items)
115 ret = NEW_YS
unsigned char[
sizeof(T) * items];
117 ret = NEW_TC
unsigned char[
sizeof(T) * items];
120 return reinterpret_cast<T*
>(
ret);
124 template <
typename T>
125 void FreeArrayMemory(T* ptr)
127 unsigned char* p =
reinterpret_cast<unsigned char*
>(ptr);
130 yaSSL::ysArrayDelete(p);
132 TaoCrypt::tcArrayDelete(p);
138 inline void* GetMemory(
size_t bytes)
140 return GetArrayMemory<unsigned char>(bytes);
144 inline void FreeMemory(
void* ptr)
146 FreeArrayMemory(ptr);
153 #endif // mySTL_HELPERS_HPP