aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/codec
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-06-26 11:17:02 +0200
committerSimon Warta <[email protected]>2015-06-27 10:57:40 +0200
commitacb8254284f6251291e4ae25ee5e3ee6302d3029 (patch)
tree32d5a697dcf94fd136180d203755918ede9d4876 /src/lib/codec
parent7df3b0226b8b491bd98198d26b6808e26d01cc60 (diff)
lib/codec: Convert &vec[0] to vec.data()
Diffstat (limited to 'src/lib/codec')
-rw-r--r--src/lib/codec/base64/base64.cpp13
-rw-r--r--src/lib/codec/base64/base64.h2
-rw-r--r--src/lib/codec/hex/hex.cpp12
-rw-r--r--src/lib/codec/hex/hex.h2
4 files changed, 17 insertions, 12 deletions
diff --git a/src/lib/codec/base64/base64.cpp b/src/lib/codec/base64/base64.cpp
index aaf04d9d2..1b1767aa1 100644
--- a/src/lib/codec/base64/base64.cpp
+++ b/src/lib/codec/base64/base64.cpp
@@ -84,9 +84,14 @@ std::string base64_encode(const byte input[],
std::string output(output_length, 0);
size_t consumed = 0;
- size_t produced = base64_encode(&output[0],
- input, input_length,
- consumed, true);
+ size_t produced = 0;
+
+ if (output_length > 0)
+ {
+ produced = base64_encode(&output.front(),
+ input, input_length,
+ consumed, true);
+ }
BOTAN_ASSERT_EQUAL(consumed, input_length, "Consumed the entire input");
BOTAN_ASSERT_EQUAL(produced, output.size(), "Produced expected size");
@@ -232,7 +237,7 @@ secure_vector<byte> base64_decode(const char input[],
: (round_up<size_t>(input_length, 4) * 3) / 4;
secure_vector<byte> bin(output_length);
- size_t written = base64_decode(&bin[0],
+ size_t written = base64_decode(bin.data(),
input,
input_length,
ignore_ws);
diff --git a/src/lib/codec/base64/base64.h b/src/lib/codec/base64/base64.h
index ab7bb5a1c..92c4dc627 100644
--- a/src/lib/codec/base64/base64.h
+++ b/src/lib/codec/base64/base64.h
@@ -49,7 +49,7 @@ std::string BOTAN_DLL base64_encode(const byte input[],
template<typename Alloc>
std::string base64_encode(const std::vector<byte, Alloc>& input)
{
- return base64_encode(&input[0], input.size());
+ return base64_encode(input.data(), input.size());
}
/**
diff --git a/src/lib/codec/hex/hex.cpp b/src/lib/codec/hex/hex.cpp
index 21c5a5a03..4da719320 100644
--- a/src/lib/codec/hex/hex.cpp
+++ b/src/lib/codec/hex/hex.cpp
@@ -41,7 +41,7 @@ std::string hex_encode(const byte input[],
std::string output(2 * input_length, 0);
if(input_length)
- hex_encode(&output[0], input, input_length, uppercase);
+ hex_encode(&output.front(), input, input_length, uppercase);
return output;
}
@@ -156,7 +156,7 @@ size_t hex_decode(byte output[],
const std::string& input,
bool ignore_ws)
{
- return hex_decode(output, &input[0], input.length(), ignore_ws);
+ return hex_decode(output, input.data(), input.length(), ignore_ws);
}
secure_vector<byte> hex_decode_locked(const char input[],
@@ -165,7 +165,7 @@ secure_vector<byte> hex_decode_locked(const char input[],
{
secure_vector<byte> bin(1 + input_length / 2);
- size_t written = hex_decode(&bin[0],
+ size_t written = hex_decode(bin.data(),
input,
input_length,
ignore_ws);
@@ -177,7 +177,7 @@ secure_vector<byte> hex_decode_locked(const char input[],
secure_vector<byte> hex_decode_locked(const std::string& input,
bool ignore_ws)
{
- return hex_decode_locked(&input[0], input.size(), ignore_ws);
+ return hex_decode_locked(input.data(), input.size(), ignore_ws);
}
std::vector<byte> hex_decode(const char input[],
@@ -186,7 +186,7 @@ std::vector<byte> hex_decode(const char input[],
{
std::vector<byte> bin(1 + input_length / 2);
- size_t written = hex_decode(&bin[0],
+ size_t written = hex_decode(bin.data(),
input,
input_length,
ignore_ws);
@@ -198,7 +198,7 @@ std::vector<byte> hex_decode(const char input[],
std::vector<byte> hex_decode(const std::string& input,
bool ignore_ws)
{
- return hex_decode(&input[0], input.size(), ignore_ws);
+ return hex_decode(input.data(), input.size(), ignore_ws);
}
}
diff --git a/src/lib/codec/hex/hex.h b/src/lib/codec/hex/hex.h
index bd57ec88e..b524c43f0 100644
--- a/src/lib/codec/hex/hex.h
+++ b/src/lib/codec/hex/hex.h
@@ -46,7 +46,7 @@ template<typename Alloc>
std::string hex_encode(const std::vector<byte, Alloc>& input,
bool uppercase = true)
{
- return hex_encode(&input[0], input.size(), uppercase);
+ return hex_encode(input.data(), input.size(), uppercase);
}
/**