From 6db8513f6b1bb89ba52b375b67b97b3fec2e1270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 8 Nov 2016 14:31:51 +0100 Subject: [PATCH] Remove unnecessary and memory inefficient code --- code/src/websockets.ino | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/code/src/websockets.ino b/code/src/websockets.ino index 54667256..f2bfa48b 100644 --- a/code/src/websockets.ino +++ b/code/src/websockets.ino @@ -30,13 +30,8 @@ bool webSocketSend(uint8_t num, char * payload) { void webSocketParse(uint8_t num, uint8_t * payload, size_t length) { // Parse JSON input - - char buffer[length+1]; - memcpy(buffer, payload, length); - buffer[length] = 0; - DynamicJsonBuffer jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(buffer); + JsonObject& root = jsonBuffer.parseObject((char *) payload); if (!root.success()) { DEBUG_MSG("[WEBSOCKET] Error parsing data\n"); return; @@ -67,6 +62,8 @@ void webSocketParse(uint8_t num, uint8_t * payload, size_t length) { for (unsigned int i=0; i