Commit 232a07a9 authored by Alexander Barkov's avatar Alexander Barkov

A clean-up for the base64 functions.

SIZEOF_INT can never be 8. Removing the redundant #ifdef code.
parent 9081c4dc
......@@ -27,24 +27,16 @@ static char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
/**
* Maximum length base64_needed_encoded_length()
* can handle without signed integer overflow: (x + 2) / 3 * 4
* can handle without signed integer overflow.
*/
int
base64_encode_max_arg_length()
{
#if (SIZEOF_INT == 8)
/*
(6827690988321067803 + 2) / 3 + 4 -> 9223372036854775805 Okey
(6827690988321067804 + 2) / 3 + 4 -> -9223372036854775807 Overflow
*/
return 0x5EC0D4C77B03531BLL; /* 6827690988321067803 */
#else
/*
1589695686 -> 2147483646 (7FFFFFFE)
1589695687 -> -2147483645
base64_needed_encoded_length(1589695686) -> 2147483646 (7FFFFFFE)
base64_needed_encoded_length(1589695687) -> -2147483645
*/
return 0x5EC0D4C6; /* 1589695686 */
#endif
}
......@@ -67,11 +59,7 @@ base64_needed_encoded_length(int length_of_data)
int
base64_decode_max_arg_length()
{
#if (SIZEOF_INT == 8)
return 0x7FFFFFFFFFFFFFFFLL;
#else
return 0x7FFFFFFF;
#endif
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment