allocate buffers to minimize .bss

This commit is contained in:
philippe44
2019-11-04 22:01:58 -08:00
parent 9b39483361
commit 5c60e505ac

View File

@@ -533,7 +533,7 @@ static void process(u8_t *pack, int len) {
static bool running;
static void slimproto_run() {
static u8_t buffer[MAXBUF];
static u8_t *buffer = NULL;
int expect = 0;
int got = 0;
u32_t now;
@@ -541,6 +541,9 @@ static void slimproto_run() {
event_handle ehandles[2];
int timeouts = 0;
// just to avoid having to free that up at multiple places
if (!buffer) buffer = malloc(MAXBUF);
set_readwake_handles(ehandles, sock, wake_e);
while (running && !new_server) {
@@ -623,12 +626,15 @@ static void slimproto_run() {
bool _start_output = false;
decode_state _decode_state;
disconnect_code disconnect_code;
static char header[MAX_HEADER];
static char *header = NULL;
size_t header_len = 0;
#if IR
bool _sendIR = false;
u32_t ir_code, ir_ts;
#endif
// just to avoid allocating it at every pass
if (!header) header = malloc(MAX_HEADER);
last = now;
LOCK_S;