summaryrefslogtreecommitdiff
path: root/src/utils/base64.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/base64.cpp')
-rw-r--r--src/utils/base64.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index b0828e99f..9f1c2a1d4 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -45,14 +45,14 @@ unsigned char *php3_base64_encode(const unsigned char *restrict const string,
int length,
int *restrict const ret_length)
{
- if (!string)
+ if (string == nullptr)
return nullptr;
const unsigned char *current = string;
int i = 0;
unsigned char *const result = static_cast<unsigned char *>(
calloc(CAST_SIZE((length + 3 - length % 3) * 4 / 3 + 1)
* sizeof(unsigned char), 1));
- if (!result)
+ if (result == nullptr)
return nullptr;
while (length > 2)
@@ -86,7 +86,7 @@ unsigned char *php3_base64_encode(const unsigned char *restrict const string,
result[i++] = base64_pad;
}
}
- if (ret_length)
+ if (ret_length != nullptr)
{
*ret_length = i;
}
@@ -105,7 +105,7 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string,
unsigned char *result = static_cast<unsigned char *>(
calloc(length + 1, 1));
- if (!result)
+ if (result == nullptr)
return nullptr;
/* run through the whole string, converting as we go */
@@ -124,7 +124,7 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string,
if (ch == ' ') ch = '+';
const char *const chp = strchr(base64_table, ch);
- if (!chp)
+ if (chp == nullptr)
continue;
ch = CAST_S32(chp - base64_table);
@@ -172,7 +172,7 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string,
break;
}
}
- if (ret_length)
+ if (ret_length != nullptr)
{
*ret_length = j;
}
@@ -187,7 +187,7 @@ std::string encodeBase64String(std::string value)
const_cast<char*>(value.c_str()));
unsigned char *const buf = php3_base64_encode(
str, CAST_S32(value.size()), &sz);
- if (!buf)
+ if (buf == nullptr)
return std::string();
value = std::string(reinterpret_cast<char*>(buf), sz);
@@ -203,7 +203,7 @@ std::string decodeBase64String(std::string value)
unsigned char *const buf = php3_base64_decode(
str, CAST_S32(value.size()), &sz);
- if (buf)
+ if (buf != nullptr)
value = std::string(reinterpret_cast<char*>(buf), sz);
else
value.clear();