mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-09-02 15:02:51 +08:00
httpd: scan the upload preamble with a register cursor
The preamble scan cursor and the buffered-length parameter carry no state between calls, so they do not need static xdata slots. As plain locals the compiler places both in registers, trimming 64 bytes of BANK1 code and two bytes of xdata. The offsets shared by config_take() stay static: direct data space is fully allocated on machines like the SWTGW218AS, so plain locals there add overlay bytes that no longer link, and xdata-class locals spill three temporaries into direct space while growing the code by roughly 120 bytes. Document pre_acc, whose accumulation across TCP segments is why it must remain global.
This commit is contained in:
+12
-9
@@ -49,6 +49,7 @@ __xdata uint8_t boundary[72];
|
|||||||
__xdata uint8_t config_upload;
|
__xdata uint8_t config_upload;
|
||||||
__xdata uint8_t config_buf[CONFIG_UPLOAD_BUF];
|
__xdata uint8_t config_buf[CONFIG_UPLOAD_BUF];
|
||||||
__xdata uint16_t cfg_pos, cfg_hdr, cfg_body, cfg_end, cfg_last;
|
__xdata uint16_t cfg_pos, cfg_hdr, cfg_body, cfg_end, cfg_last;
|
||||||
|
// part-header bytes buffered so far; accumulates across TCP segments
|
||||||
__xdata uint16_t pre_acc;
|
__xdata uint16_t pre_acc;
|
||||||
__xdata uint8_t cfg_bl;
|
__xdata uint8_t cfg_bl;
|
||||||
__xdata uint8_t * __xdata content_type = 0;
|
__xdata uint8_t * __xdata content_type = 0;
|
||||||
@@ -381,20 +382,22 @@ static uint8_t config_take(void)
|
|||||||
|
|
||||||
|
|
||||||
// unlike scan_header(), keeps no auth state, so it may run on every buffered segment
|
// unlike scan_header(), keeps no auth state, so it may run on every buffered segment
|
||||||
static uint16_t preamble_payload_start(__xdata uint16_t n)
|
static uint16_t preamble_payload_start(uint16_t n)
|
||||||
{
|
{
|
||||||
for (cfg_pos = 0; cfg_pos + 24 <= n; cfg_pos++) {
|
uint16_t pos;
|
||||||
if (strstart(&config_buf[cfg_pos], "application/octet-stream"))
|
|
||||||
|
for (pos = 0; pos + 24 <= n; pos++) {
|
||||||
|
if (strstart(&config_buf[pos], "application/octet-stream"))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (cfg_pos + 24 > n)
|
if (pos + 24 > n)
|
||||||
return 0;
|
return 0;
|
||||||
cfg_pos += 24;
|
pos += 24;
|
||||||
while (cfg_pos + 3 < n && !strstart(&config_buf[cfg_pos], "\r\n\r\n"))
|
while (pos + 3 < n && !strstart(&config_buf[pos], "\r\n\r\n"))
|
||||||
cfg_pos++;
|
pos++;
|
||||||
if (cfg_pos + 3 >= n)
|
if (pos + 3 >= n)
|
||||||
return 0;
|
return 0;
|
||||||
return cfg_pos + 4;
|
return pos + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user