diff options
author | Jack Lloyd <[email protected]> | 2017-11-16 16:34:39 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-11-16 16:34:39 -0500 |
commit | a8e8b52f9957df12e51d81c128b1a117e5366e1d (patch) | |
tree | b407bc912904538c66a2118f393413a85b6dbafc | |
parent | 4e619d418353dbee933dee1cf05471162118cc9f (diff) | |
parent | ce397a06d1285f38195f91f08e2712307277df62 (diff) |
Merge GH #1296 Allow using secure_allocator with std::string under VC2013
-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); } |