From 41fbbc10106356b3e4832fc9241c31e7ad2ad5f1 Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Wed, 8 Nov 2023 08:44:39 +0100 Subject: [PATCH 1/2] fix memory overlap in deviceBuffer --- src/allocateMem.cpp | 6 +++--- src/allocateMem.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/allocateMem.cpp b/src/allocateMem.cpp index 2fcf2d49..0e2c3789 100644 --- a/src/allocateMem.cpp +++ b/src/allocateMem.cpp @@ -15,9 +15,9 @@ std::size_t deviceBuffer[MF_MAX_DEVICEMEM] = {0}; uint16_t nextPointer = 0; #if defined (ARDUINO_ARCH_AVR) -uint8_t *allocateMemory(uint8_t size) +uint8_t *allocateMemory(uint16_t size) #else -std::size_t *allocateMemory(uint8_t size) +std::size_t *allocateMemory(uint16_t size) #endif { uint16_t actualPointer = nextPointer; @@ -49,7 +49,7 @@ uint16_t GetAvailableMemory() return MF_MAX_DEVICEMEM - nextPointer; } -bool FitInMemory(uint8_t size) +bool FitInMemory(uint16_t size) { if (nextPointer + size > MF_MAX_DEVICEMEM) return false; diff --git a/src/allocateMem.h b/src/allocateMem.h index e9d6f857..9ee4ab56 100644 --- a/src/allocateMem.h +++ b/src/allocateMem.h @@ -9,13 +9,13 @@ #include #if defined (ARDUINO_ARCH_AVR) -uint8_t *allocateMemory(uint8_t size); +uint8_t *allocateMemory(uint16_t size); #else std::size_t *allocateMemory(uint8_t size); #endif void ClearMemory(); uint16_t GetAvailableMemory(); -bool FitInMemory(uint8_t size); +bool FitInMemory(uint16_t size); // allocatemem.h From e0c6515f2f2cd470dda45970a3f2da31daab4263 Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:35:52 +0100 Subject: [PATCH 2/2] correct size also for picos --- src/allocateMem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/allocateMem.h b/src/allocateMem.h index 9ee4ab56..4ffb3e04 100644 --- a/src/allocateMem.h +++ b/src/allocateMem.h @@ -11,7 +11,7 @@ #if defined (ARDUINO_ARCH_AVR) uint8_t *allocateMemory(uint16_t size); #else -std::size_t *allocateMemory(uint8_t size); +std::size_t *allocateMemory(uint16_t size); #endif void ClearMemory();