diff options
author | Ivan Shapovalov <intelfx@intelfx.name> | 2016-10-15 20:45:10 +0300 |
---|---|---|
committer | Ivan Shapovalov <intelfx@intelfx.name> | 2016-10-22 07:25:16 +0300 |
commit | 6ac7edd2da7e6aa1882a42b09ef41c749438cef0 (patch) | |
tree | fb2a8e79a3d82b70f2454f46e222ce46a7e64824 /src/clpp11.hpp | |
parent | 106565fa9ad1f12df650dbc02bff27bd0b79de6a (diff) |
src/clpp11.hpp: GetInfoString: avoid reallocation
Diffstat (limited to 'src/clpp11.hpp')
-rw-r--r-- | src/clpp11.hpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/clpp11.hpp b/src/clpp11.hpp index f6855349..b52d5a3f 100644 --- a/src/clpp11.hpp +++ b/src/clpp11.hpp @@ -43,6 +43,7 @@ #include <memory> // std::shared_ptr #include <stdexcept> // std::runtime_error #include <numeric> // std::accumulate +#include <cstring> // std::strlen // OpenCL #if defined(__APPLE__) || defined(__MACOSX) @@ -283,7 +284,8 @@ class Device { auto result = std::string{}; result.resize(bytes); CheckError(clGetDeviceInfo(device_, info, bytes, &result[0], nullptr)); - return std::string{result.c_str()}; // Removes any trailing '\0'-characters + result.resize(strlen(result.c_str())); // Removes any trailing '\0'-characters + return result; } }; |