diff options
Diffstat (limited to 'include/winapi')
-rw-r--r-- | include/winapi/buffer.hpp | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/include/winapi/buffer.hpp b/include/winapi/buffer.hpp index 11d029f..08094f8 100644 --- a/include/winapi/buffer.hpp +++ b/include/winapi/buffer.hpp @@ -5,8 +5,6 @@ #pragma once -#include <SafeInt.hpp> - #include <cstddef> #include <cstring> #include <initializer_list> @@ -37,11 +35,7 @@ public: template <typename CharT> void set(const std::basic_string<CharT>& src) { - std::size_t new_size = 0; - if (!SafeMultiply(src.length(), sizeof(std::basic_string<CharT>::char_type), new_size)) { - throw std::runtime_error{"Destination buffer size is too large"}; - } - set(src.c_str(), new_size); + set(src.c_str(), src.length() * sizeof(std::basic_string<CharT>::char_type)); } void set(const void* src, std::size_t nb) { @@ -70,13 +64,7 @@ public: void add(const Buffer& src) { const auto nb = size(); - { - std::size_t new_size = 0; - if (!SafeAdd(size(), src.size(), new_size)) { - throw std::runtime_error{"Destination buffer size is too large"}; - } - resize(new_size); - } + resize(nb + src.size()); std::memcpy(data() + nb, src.data(), src.size()); } }; |