From d724864095abee771ba6f603744ece811f164af9 Mon Sep 17 00:00:00 2001 From: Edwin vd Oetelaar PA2LVD Date: Sun, 26 Jun 2016 20:53:07 +0200 Subject: [PATCH] Reduce stack usage in loop(). No need to duplicate topic string onto stack before giving it to callback() Just move it one byte in buffer to add space for 'C' string end \0x00 --- src/PubSubClient.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PubSubClient.cpp b/src/PubSubClient.cpp index 9658c4a..5932bdb 100755 --- a/src/PubSubClient.cpp +++ b/src/PubSubClient.cpp @@ -306,12 +306,10 @@ boolean PubSubClient::loop() { uint8_t type = buffer[0]&0xF0; if (type == MQTTPUBLISH) { if (callback) { - uint16_t tl = (buffer[llen+1]<<8)+buffer[llen+2]; - char topic[tl+1]; - for (uint16_t i=0;i0 if ((buffer[0]&0x06) == MQTTQOS1) { msgId = (buffer[llen+3+tl]<<8)+buffer[llen+3+tl+1];