diff --git a/src/TinyMqtt.cpp b/src/TinyMqtt.cpp index da96ee1..74ca4b1 100644 --- a/src/TinyMqtt.cpp +++ b/src/TinyMqtt.cpp @@ -672,6 +672,7 @@ void MqttMessage::add(const char* p, size_t len, bool addLength) { if (addLength) { + buffer.reserve(buffer.length()+addLength+2); incoming(len>>8); incoming(len & 0xFF); } diff --git a/src/TinyMqtt.h b/src/TinyMqtt.h index ee9692e..d6dc2db 100644 --- a/src/TinyMqtt.h +++ b/src/TinyMqtt.h @@ -80,23 +80,15 @@ class MqttMessage // output buff+=2, len=length(str) static void getString(const char* &buff, uint16_t& len); - Type type() const { return state == Complete ? static_cast(buffer[0]) : Unknown; } - // shouldn't exist because it breaks constness :-( - // but this saves memory so ... - void changeType(Type type) const - { - buffer[0] = type; - } - void create(Type type) { buffer=(char)type; - buffer+='\0'; + buffer+='\0'; // reserved for msg length vheader=2; size=0; state=Create; diff --git a/tests/Makefile b/tests/Makefile index bfea400..e2d6bac 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -5,7 +5,7 @@ tests: $(MAKE) -C $$(dirname $$i) -j; \ done -runtests: +runtests: tests set -e; \ for i in *-tests/Makefile; do \ echo '==== Running:' $$(dirname $$i); \