diff options
author | Daniel Neus <[email protected]> | 2017-11-16 19:58:20 +0100 |
---|---|---|
committer | Daniel Neus <[email protected]> | 2017-11-16 19:58:20 +0100 |
commit | ce397a06d1285f38195f91f08e2712307277df62 (patch) | |
tree | eda8daae051a4f70eaa2d00040b95c434a3e528a /src/lib/base | |
parent | 966498893af60a1474ea10f1dc3bfbd5b1f43d00 (diff) |
Fix secure_allocator with std::string on VS2013
Closes #1295
Diffstat (limited to 'src/lib/base')
-rw-r--r-- | src/lib/base/secmem.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/lib/base/secmem.h b/src/lib/base/secmem.h index 80dc69c14..9449d015e 100644 --- a/src/lib/base/secmem.h +++ b/src/lib/base/secmem.h @@ -40,6 +40,22 @@ class secure_allocator secure_allocator(const secure_allocator&) = default; secure_allocator& operator=(const secure_allocator&) = default; ~secure_allocator() = default; + + template <typename U> + struct rebind + { + typedef secure_allocator<U> other; + }; + + void construct(value_type* mem, const value_type& value) + { + std::_Construct(mem, value); + } + + void destroy(value_type* mem) + { + std::_Destroy(mem); + } #else secure_allocator() BOTAN_NOEXCEPT = default; secure_allocator(const secure_allocator&) BOTAN_NOEXCEPT = default; @@ -90,7 +106,7 @@ size_t buffer_insert(std::vector<T, Alloc>& buf, size_t input_length) { const size_t to_copy = std::min(input_length, buf.size() - buf_offset); - if (to_copy > 0) + if(to_copy > 0) { copy_mem(&buf[buf_offset], input, to_copy); } @@ -103,7 +119,7 @@ size_t buffer_insert(std::vector<T, Alloc>& buf, const std::vector<T, Alloc2>& input) { const size_t to_copy = std::min(input.size(), buf.size() - buf_offset); - if (to_copy > 0) + if(to_copy > 0) { copy_mem(&buf[buf_offset], input.data(), to_copy); } @@ -117,7 +133,7 @@ operator+=(std::vector<T, Alloc>& out, { const size_t copy_offset = out.size(); out.resize(out.size() + in.size()); - if (in.size() > 0) + if(in.size() > 0) { copy_mem(&out[copy_offset], in.data(), in.size()); } @@ -137,7 +153,7 @@ std::vector<T, Alloc>& operator+=(std::vector<T, Alloc>& out, { const size_t copy_offset = out.size(); out.resize(out.size() + in.second); - if (in.second > 0) + if(in.second > 0) { copy_mem(&out[copy_offset], in.first, in.second); } @@ -150,7 +166,7 @@ std::vector<T, Alloc>& operator+=(std::vector<T, Alloc>& out, { const size_t copy_offset = out.size(); out.resize(out.size() + in.second); - if (in.second > 0) + if(in.second > 0) { copy_mem(&out[copy_offset], in.first, in.second); } |