diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-02-07 16:18:13 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-02-07 16:18:13 +0300 |
commit | 9fe21fcd8883b37bdc30224822e6e42afb35b8f0 (patch) | |
tree | 798117abd4dc7e610997d59d530a96ddc1509f53 /src/utils/base64.cpp | |
parent | 4429cb14e9e187edef27aba692a4266733f79c17 (diff) | |
download | plus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.gz plus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.bz2 plus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.xz plus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.zip |
Replace most static_cast<Type> to shorter versions from defines.
Diffstat (limited to 'src/utils/base64.cpp')
-rw-r--r-- | src/utils/base64.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index 7be63c090..ddf117ec4 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -50,7 +50,7 @@ unsigned char *php3_base64_encode(const unsigned char *restrict const string, const unsigned char *current = string; int i = 0; unsigned char *const result = static_cast<unsigned char *>( - calloc(static_cast<size_t>((length + 3 - length % 3) * 4 / 3 + 1) + calloc(CAST_SIZE((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(unsigned char), 1)); if (!result) return nullptr; @@ -126,23 +126,23 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string, const char *const chp = strchr(base64_table, ch); if (!chp) continue; - ch = static_cast<int>(chp - base64_table); + ch = CAST_S32(chp - base64_table); switch (i % 4) { case 0: - result[j] = static_cast<unsigned char>(ch << 2U); + result[j] = CAST_U8(ch << 2U); break; case 1: - result[j++] |= static_cast<unsigned char>(ch >> 4U); - result[j] = static_cast<unsigned char>((ch & 0x0f) << 4U); + result[j++] |= CAST_U8(ch >> 4U); + result[j] = CAST_U8((ch & 0x0f) << 4U); break; case 2: - result[j++] |= static_cast<unsigned char>(ch >>2U); - result[j] = static_cast<unsigned char>((ch & 0x03) << 6U); + result[j++] |= CAST_U8(ch >>2U); + result[j] = CAST_U8((ch & 0x03) << 6U); break; case 3: - result[j++] |= static_cast<unsigned char>(ch); + result[j++] |= CAST_U8(ch); break; default: break; @@ -183,7 +183,7 @@ std::string encodeBase64String(std::string value) const unsigned char *const str = reinterpret_cast<unsigned char*>( const_cast<char*>(value.c_str())); unsigned char *const buf = php3_base64_encode( - str, static_cast<int>(value.size()), &sz); + str, CAST_S32(value.size()), &sz); if (!buf) return std::string(); @@ -198,7 +198,7 @@ std::string decodeBase64String(std::string value) const unsigned char *const str = reinterpret_cast<unsigned char*>( const_cast<char*>(value.c_str())); unsigned char *const buf = php3_base64_decode( - str, static_cast<int>(value.size()), &sz); + str, CAST_S32(value.size()), &sz); if (buf) value = std::string(reinterpret_cast<char*>(buf), sz); |