summaryrefslogtreecommitdiff
path: root/src/base64.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-10-01 20:42:10 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-10-03 22:21:53 -0400
commit7aff5046ace2e6e776b2a1bd6406acfc727b8ff5 (patch)
tree5b80369c7db633bd64c0fb830766cb3bd2c18475 /src/base64.c
parentc49f5150961542300069258bd48aa2004dc2213c (diff)
downloadlighttpd-git-7aff5046ace2e6e776b2a1bd6406acfc727b8ff5.tar.gz
[unittests] consolidate base64 test code
consolidate base64 test code use char type for tables to reduce memory use (potentially increase cache hits)
Diffstat (limited to 'src/base64.c')
-rw-r--r--src/base64.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/base64.c b/src/base64.c
index 35e6a70d..f39dbaa2 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -10,8 +10,8 @@
*/
/* BASE64_STANDARD: "A-Z a-z 0-9 + /" maps to 0-63, pad with "=" */
-static const char base64_standard_table[66] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
-static const short base64_standard_reverse_table[128] = {
+static const char base64_standard_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+static const char base64_standard_reverse_table[] = {
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
-1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x00 - 0x0F */
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x10 - 0x1F */
@@ -24,8 +24,8 @@ static const short base64_standard_reverse_table[128] = {
};
/* BASE64_URL: "A-Z a-z 0-9 - _" maps to 0-63, pad with "." */
-static const char base64_url_table[66] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
-static const short base64_url_reverse_table[128] = {
+static const char base64_url_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
+static const char base64_url_reverse_table[] = {
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
-1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x00 - 0x0F */
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x10 - 0x1F */
@@ -42,7 +42,7 @@ unsigned char* buffer_append_base64_decode(buffer *out, const char* in, size_t i
size_t out_pos = 0; /* current output character (position) that is decoded. can contain partial result */
unsigned int group = 0; /* how many base64 digits in the current group were decoded already. each group has up to 4 digits */
size_t i;
- const short* base64_reverse_table;
+ const char *base64_reverse_table;
switch (charset) {
case BASE64_STANDARD:
@@ -60,7 +60,7 @@ unsigned char* buffer_append_base64_decode(buffer *out, const char* in, size_t i
/* run through the whole string, converting as we go */
for (i = 0; i < in_length; i++) {
unsigned char c = (unsigned char) in[i];
- short ch;
+ int ch;
if (c == '\0') break;
if (c >= 128) return NULL; /* only 7-bit characters allowed */