Fixed error in default_init_allocator, it should not construct objects, only allocate raw memory.

[SVN r85999]
This commit is contained in:
Ion Gaztañaga committed 2013-09-29 11:39:34 +00:00
1 parent 232e18956a
commit 59c5ed7781
2 files changed
+5 -13

No files matched your search

+5 -5
View File
@@ -78,9 +78,9 @@ class default_init_allocator
T* allocate(std::size_t n)
{
//Initialize memory to a pattern
T *const p = ::new T[n];
unsigned char *puc_raw = reinterpret_cast<unsigned char*>(p);
std::size_t max = sizeof(T)*n;
const std::size_t max = sizeof(T)*n;
unsigned char *puc_raw = ::new unsigned char[max];
if(base_t::s_ascending){
for(std::size_t i = 0; i != max; ++i){
puc_raw[i] = static_cast<unsigned char>(s_pattern++);
@@ -91,11 +91,11 @@ class default_init_allocator
puc_raw[i] = static_cast<unsigned char>(s_pattern--);
}
}
return p;
return (T*)puc_raw;;
}
void deallocate(T *p, std::size_t)
{ delete[] p; }
{ delete[] (unsigned char*)p; }
};
template<class T>