From 52e3bec6564a77850b97bf222786924b4c8f3668 Mon Sep 17 00:00:00 2001 From: Michael Geramb Date: Sat, 18 Nov 2023 21:17:28 +0100 Subject: [PATCH] Optimized size of CallContext buffer sizes --- src/CallContext.cpp | 3 +-- src/CallContext.h | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CallContext.cpp b/src/CallContext.cpp index 1219f89..97e8efb 100644 --- a/src/CallContext.cpp +++ b/src/CallContext.cpp @@ -33,7 +33,7 @@ #include CallContext::CallContext() - : stringBuffer(1024, "CallContext stringBuffer") + : stringBuffer(MINIMUM_STRING_BUFFER_SIZE, "CallContext stringBuffer") { } @@ -48,7 +48,6 @@ void CallContext::printf(const char* format, ...) va_end(ap); } - char* CallContext::reserveStringBuffer(int stringLength) { int requiredNewBufferLength = stringLength + 1; // reserve buffer for characters and string terminator '\0' diff --git a/src/CallContext.h b/src/CallContext.h index c657ff0..4970dd9 100644 --- a/src/CallContext.h +++ b/src/CallContext.h @@ -36,6 +36,7 @@ struct HAPClient; class CallContext { + static const int MINIMUM_STRING_BUFFER_SIZE=1006; // Same as framesize for SendEncryptedCallContext private: TempBuffer stringBuffer; int usedStringLength = 0; @@ -55,7 +56,7 @@ protected: class SendEncryptedCallContext : public CallContext { - static const int FRAME_SIZE=1024; // number of bytes to use in each ChaCha20-Poly1305 encrypted frame when sending encrypted JSON content to Client + static const int FRAME_SIZE=1006; // 1024 - AAD - Auth // number of bytes to use in each ChaCha20-Poly1305 encrypted frame when sending encrypted JSON content to Client HAPClient& hapClient; TempBuffer sendBuffer;