浏览代码

allocate buffers to minimize .bss

philippe44 5 年之前
父节点
当前提交
5c60e505ac
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      components/squeezelite/slimproto.c

+ 8 - 2
components/squeezelite/slimproto.c

@@ -533,13 +533,16 @@ 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;
 	static u32_t last = 0;
 	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);
 
@@ -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;