From fcb249320e9529c772fde21195659cc81cb57c73 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 23 Jun 2015 18:22:19 +0200 Subject: lib/utils: Convert &vec[0] to vec.data() --- src/lib/utils/datastor/datastor.cpp | 4 ++-- src/lib/utils/http_util/http_util.cpp | 6 +++--- src/lib/utils/loadstor.h | 4 ++-- src/lib/utils/stl_util.h | 3 +-- src/lib/utils/xor_buf.h | 8 ++++---- 5 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src/lib') diff --git a/src/lib/utils/datastor/datastor.cpp b/src/lib/utils/datastor/datastor.cpp index 344c03f7c..69c1bf453 100644 --- a/src/lib/utils/datastor/datastor.cpp +++ b/src/lib/utils/datastor/datastor.cpp @@ -141,12 +141,12 @@ void Data_Store::add(const std::string& key, u32bit val) */ void Data_Store::add(const std::string& key, const secure_vector& val) { - add(key, hex_encode(&val[0], val.size())); + add(key, hex_encode(val.data(), val.size())); } void Data_Store::add(const std::string& key, const std::vector& val) { - add(key, hex_encode(&val[0], val.size())); + add(key, hex_encode(val.data(), val.size())); } /* diff --git a/src/lib/utils/http_util/http_util.cpp b/src/lib/utils/http_util/http_util.cpp index 913d4fd19..1a15d6418 100644 --- a/src/lib/utils/http_util/http_util.cpp +++ b/src/lib/utils/http_util/http_util.cpp @@ -123,7 +123,7 @@ Response http_sync(http_exch_fn http_transact, if(content_type != "") outbuf << "Content-Type: " << content_type << "\r\n"; outbuf << "Connection: close\r\n\r\n"; - outbuf.write(reinterpret_cast(&body[0]), body.size()); + outbuf.write(reinterpret_cast(body.data()), body.size()); std::istringstream io(http_transact(hostname, outbuf.str())); @@ -171,8 +171,8 @@ Response http_sync(http_exch_fn http_transact, std::vector buf(4096); while(io.good()) { - io.read(reinterpret_cast(&buf[0]), buf.size()); - resp_body.insert(resp_body.end(), &buf[0], &buf[io.gcount()]); + io.read(reinterpret_cast(buf.data()), buf.size()); + resp_body.insert(resp_body.end(), buf.data(), &buf[io.gcount()]); } const std::string header_size = search_map(headers, std::string("Content-Length")); diff --git a/src/lib/utils/loadstor.h b/src/lib/utils/loadstor.h index 4db3d07fa..d3871480c 100644 --- a/src/lib/utils/loadstor.h +++ b/src/lib/utils/loadstor.h @@ -641,7 +641,7 @@ void copy_out_be(byte out[], size_t out_bytes, const T in[]) template void copy_out_vec_be(byte out[], size_t out_bytes, const std::vector& in) { - copy_out_be(out, out_bytes, &in[0]); + copy_out_be(out, out_bytes, in.data()); } template @@ -662,7 +662,7 @@ void copy_out_le(byte out[], size_t out_bytes, const T in[]) template void copy_out_vec_le(byte out[], size_t out_bytes, const std::vector& in) { - copy_out_le(out, out_bytes, &in[0]); + copy_out_le(out, out_bytes, in.data()); } } diff --git a/src/lib/utils/stl_util.h b/src/lib/utils/stl_util.h index 06f09498e..76cf77ef8 100644 --- a/src/lib/utils/stl_util.h +++ b/src/lib/utils/stl_util.h @@ -16,8 +16,7 @@ namespace Botan { inline std::vector to_byte_vector(const std::string& s) { - return std::vector(reinterpret_cast(&s[0]), - reinterpret_cast(&s[s.size()])); + return std::vector(s.cbegin(), s.cend()); } /* diff --git a/src/lib/utils/xor_buf.h b/src/lib/utils/xor_buf.h index 967348d4c..23151f72e 100644 --- a/src/lib/utils/xor_buf.h +++ b/src/lib/utils/xor_buf.h @@ -107,7 +107,7 @@ void xor_buf(std::vector& out, const std::vector& in, size_t n) { - xor_buf(&out[0], &in[0], n); + xor_buf(out.data(), in.data(), n); } template @@ -115,7 +115,7 @@ void xor_buf(std::vector& out, const byte* in, size_t n) { - xor_buf(&out[0], in, n); + xor_buf(out.data(), in, n); } template @@ -124,7 +124,7 @@ void xor_buf(std::vector& out, const std::vector& in2, size_t n) { - xor_buf(&out[0], &in[0], &in2[0], n); + xor_buf(out.data(), in, in2.data(), n); } template @@ -135,7 +135,7 @@ operator^=(std::vector& out, if(out.size() < in.size()) out.resize(in.size()); - xor_buf(&out[0], &in[0], in.size()); + xor_buf(out.data(), in.data(), in.size()); return out; } -- cgit v1.2.3