Skip to content

Commit

Permalink
Beta - Fix memory overlap in DeviceBuffer (#272)
Browse files Browse the repository at this point in the history
* fix memory overlap in deviceBuffer
* correct size also for picos
  • Loading branch information
elral authored Nov 8, 2023
1 parent ca3c5bb commit d874cf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/allocateMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/allocateMem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#include <new>

#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

void ClearMemory();
uint16_t GetAvailableMemory();
bool FitInMemory(uint8_t size);
bool FitInMemory(uint16_t size);

// allocatemem.h

0 comments on commit d874cf8

Please sign in to comment.