diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-04 15:16:14 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-04 15:16:21 +0300 |
commit | 3d3d391aed616abf8754621c8246a500dddef788 (patch) | |
tree | 678a54fbf7c530fc79dadebbc2c03e694d0ad746 /include/winapi | |
parent | update winapi-utf8 (diff) | |
download | winapi-common-3d3d391aed616abf8754621c8246a500dddef788.tar.gz winapi-common-3d3d391aed616abf8754621c8246a500dddef788.zip |
get rid of SafeInt
Diffstat (limited to '')
-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()); } }; |