Skip to content

Commit 63607e6

Browse files
jgstrouddkerr64
authored andcommitted
Free up 512B of RAM in the http_parser
(cherry picked from commit e85342a)
1 parent e07e5e6 commit 63607e6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/http_parser.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static const char *method_strings[] =
186186
* | "/" | "[" | "]" | "?" | "="
187187
* | "{" | "}" | SP | HT
188188
*/
189-
static const char tokens[256] = {
189+
static const PROGMEM char tokens[256] = {
190190
/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */
191191
0, 0, 0, 0, 0, 0, 0, 0,
192192
/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */
@@ -221,7 +221,7 @@ static const char tokens[256] = {
221221
'x', 'y', 'z', 0, '|', 0, '~', 0 };
222222

223223

224-
static const int8_t unhex[256] =
224+
static const PROGMEM char unhex[256] =
225225
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
226226
,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
227227
,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
@@ -421,10 +421,10 @@ enum http_host_state
421421
(c) == ';' || (c) == ':' || (c) == '&' || (c) == '=' || (c) == '+' || \
422422
(c) == '$' || (c) == ',')
423423

424-
#define STRICT_TOKEN(c) (tokens[(unsigned char)c])
424+
#define STRICT_TOKEN(c) (pgm_read_byte(tokens+c))
425425

426426
#if HTTP_PARSER_STRICT
427-
#define TOKEN(c) (tokens[(unsigned char)c])
427+
#define TOKEN(c) (pgm_read_byte(tokens + c))
428428
#define IS_URL_CHAR(c) (BIT_AT(normal_url_char, (unsigned char)c))
429429
#define IS_HOST_CHAR(c) (IS_ALPHANUM(c) || (c) == '.' || (c) == '-')
430430
#else
@@ -1937,7 +1937,7 @@ size_t http_parser_execute (http_parser *parser,
19371937
assert(parser->nread == 1);
19381938
assert(parser->flags & F_CHUNKED);
19391939

1940-
unhex_val = unhex[(unsigned char)ch];
1940+
unhex_val = pgm_read_byte(unhex + ch);
19411941
if (UNLIKELY(unhex_val == -1)) {
19421942
SET_ERRNO(HPE_INVALID_CHUNK_SIZE);
19431943
goto error;
@@ -1959,7 +1959,7 @@ size_t http_parser_execute (http_parser *parser,
19591959
break;
19601960
}
19611961

1962-
unhex_val = unhex[(unsigned char)ch];
1962+
unhex_val = pgm_read_byte(unhex + ch);
19631963

19641964
if (unhex_val == -1) {
19651965
if (ch == ';' || ch == ' ') {

0 commit comments

Comments
 (0)