From 3d3d391aed616abf8754621c8246a500dddef788 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 4 May 2021 15:16:14 +0300 Subject: get rid of SafeInt --- include/winapi/buffer.hpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'include/winapi') 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 - #include #include #include @@ -37,11 +35,7 @@ public: template void set(const std::basic_string& src) { - std::size_t new_size = 0; - if (!SafeMultiply(src.length(), sizeof(std::basic_string::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::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()); } }; -- cgit v1.2.3