Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions MemoryFree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <WProgram.h>
#endif

#include <stdint.h>

extern unsigned int __heap_start;
extern void *__brkval;

Expand Down Expand Up @@ -39,13 +41,13 @@ int freeListSize()
int freeMemory()
{
int free_memory;
if ((int)__brkval == 0)
if ((intptr_t)__brkval == 0)
{
free_memory = ((int)&free_memory) - ((int)&__heap_start);
free_memory = ((intptr_t)&free_memory) - ((intptr_t)&__heap_start);
}
else
{
free_memory = ((int)&free_memory) - ((int)__brkval);
free_memory = ((intptr_t)&free_memory) - ((intptr_t)__brkval);
free_memory += freeListSize();
}
return free_memory;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ This is the excellent MemoryFree library from http://www.arduino.cc/playground/C
I am hosting it here so there is a quick and easy way to pull it down.

(20 Mar 2015) Repository updated with code from http://playground.arduino.cc/code/AvailableMemory
(17 Jan 2021) Replaced 'int' type with 'intptr_t' type in pointer arithmetic for compiling without -fpermisive