1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-02-07 07:44:13 +00:00

Workaround c++11 dynamic array for MSVC

This commit is contained in:
Mikhail Titov 2016-03-07 02:08:08 -06:00
parent 5ffe1893cd
commit 74827cd8cf

View File

@ -244,21 +244,20 @@ namespace data
size_t IdentityEx::FromBase64(const std::string& s) size_t IdentityEx::FromBase64(const std::string& s)
{ {
const size_t slen = s.length(); const size_t slen = s.length();
uint8_t buf[slen]; // binary data can't exceed base64 std::vector<uint8_t> buf(slen); // binary data can't exceed base64
const size_t len = Base64ToByteStream (s.c_str(), slen, buf, slen); const size_t len = Base64ToByteStream (s.c_str(), slen, buf.data(), slen);
return FromBuffer (buf, len); return FromBuffer (buf.data(), len);
} }
std::string IdentityEx::ToBase64 () const std::string IdentityEx::ToBase64 () const
{ {
const size_t bufLen = GetFullLen(); const size_t bufLen = GetFullLen();
const size_t strLen = Base64EncodingBufferSize(bufLen); const size_t strLen = Base64EncodingBufferSize(bufLen);
uint8_t buf[bufLen]; std::vector<uint8_t> buf(bufLen);
char str[strLen]; std::vector<char> str(strLen);
size_t l = ToBuffer (buf, bufLen); size_t l = ToBuffer (buf.data(), bufLen);
size_t l1 = i2p::data::ByteStreamToBase64 (buf, l, str, strLen); size_t l1 = i2p::data::ByteStreamToBase64 (buf.data(), l, str.data(), strLen);
str[l1] = 0; return std::string (str.data(), l1);
return std::string (str);
} }
size_t IdentityEx::GetSigningPublicKeyLen () const size_t IdentityEx::GetSigningPublicKeyLen () const