aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-05-04 15:16:14 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-05-04 15:16:21 +0300
commit3d3d391aed616abf8754621c8246a500dddef788 (patch)
tree678a54fbf7c530fc79dadebbc2c03e694d0ad746
parentupdate winapi-utf8 (diff)
downloadwinapi-common-3d3d391aed616abf8754621c8246a500dddef788.tar.gz
winapi-common-3d3d391aed616abf8754621c8246a500dddef788.zip
get rid of SafeInt
Diffstat (limited to '')
-rw-r--r--.gitmodules3
m---------3rdparty/microsoft/SafeInt0
-rw-r--r--CMakeLists.txt4
-rw-r--r--include/winapi/buffer.hpp16
-rw-r--r--src/cmd_line.cpp4
5 files changed, 3 insertions, 24 deletions
diff --git a/.gitmodules b/.gitmodules
index 99998f2..9ea0616 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,6 +4,3 @@
[submodule "3rdparty/winapi/utf8"]
path = 3rdparty/winapi/utf8
url = https://github.com/egor-tensin/winapi-utf8.git
-[submodule "3rdparty/microsoft/SafeInt"]
- path = 3rdparty/microsoft/SafeInt
- url = https://github.com/dcleblanc/SafeInt.git
diff --git a/3rdparty/microsoft/SafeInt b/3rdparty/microsoft/SafeInt
deleted file mode 160000
-Subproject a5408ba2c025ec99a7afb6ccca907d5a263242a
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f3b6749..8553200 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,9 +6,6 @@ enable_testing()
include(cmake/common.cmake)
find_package(Boost REQUIRED)
-if(NOT TARGET SafeInt)
- add_subdirectory(3rdparty/microsoft/SafeInt EXCLUDE_FROM_ALL)
-endif()
add_subdirectory(3rdparty/winapi/utf8 EXCLUDE_FROM_ALL)
file(GLOB_RECURSE winapi_common_include "include/*.hpp")
@@ -16,7 +13,6 @@ file(GLOB winapi_common_src "src/*.cpp")
add_library(winapi_common ${winapi_common_include} ${winapi_common_src})
target_include_directories(winapi_common PUBLIC include)
target_link_libraries(winapi_common PRIVATE winapi_utf8)
-target_link_libraries(winapi_common PUBLIC SafeInt)
target_link_libraries(winapi_common PUBLIC Boost::disable_autolinking Boost::boost)
install(TARGETS winapi_common ARCHIVE DESTINATION lib)
install(DIRECTORY include/winapi DESTINATION include)
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());
}
};
diff --git a/src/cmd_line.cpp b/src/cmd_line.cpp
index 238e0bc..d2eeab5 100644
--- a/src/cmd_line.cpp
+++ b/src/cmd_line.cpp
@@ -8,8 +8,6 @@
#include <winapi/utf8.hpp>
#include <winapi/utils.hpp>
-#include <SafeInt.hpp>
-
#include <boost/algorithm/string.hpp>
#include <boost/config.hpp>
@@ -102,7 +100,7 @@ std::string CommandLine::escape(const std::string& arg) {
safe << '"';
for (auto it = arg.cbegin(); it != arg.cend(); ++it) {
- SafeInt<std::size_t> numof_backslashes{0};
+ std::size_t numof_backslashes = 0;
for (; it != arg.cend() && *it == '\\'; ++it)
++numof_backslashes;