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,13 +533,16 @@ static void process(u8_t *pack, int len) {
static bool running; static bool running;
static void slimproto_run() { static void slimproto_run() {
static u8_t buffer[MAXBUF]; static u8_t *buffer = NULL;
int expect = 0; int expect = 0;
int got = 0; int got = 0;
u32_t now; u32_t now;
static u32_t last = 0; static u32_t last = 0;
event_handle ehandles[2]; event_handle ehandles[2];
int timeouts = 0; 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); set_readwake_handles(ehandles, sock, wake_e);
@@ -623,12 +626,15 @@ static void slimproto_run() {
bool _start_output = false; bool _start_output = false;
decode_state _decode_state; decode_state _decode_state;
disconnect_code disconnect_code; disconnect_code disconnect_code;
static char header[MAX_HEADER]; static char *header = NULL;
size_t header_len = 0; size_t header_len = 0;
#if IR #if IR
bool _sendIR = false; bool _sendIR = false;
u32_t ir_code, ir_ts; u32_t ir_code, ir_ts;
#endif #endif
// just to avoid allocating it at every pass
if (!header) header = malloc(MAX_HEADER);
last = now; last = now;
LOCK_S; LOCK_S;