fix(color): Return actual free memory avail from 'malloc/new' calls in 'availableMemory' (#3512)

This commit is contained in:
philmoz
2023-05-07 11:14:01 +10:00
committed by GitHub
parent 140c700e1e
commit cea26d1247
2 changed files with 18 additions and 8 deletions
+17
View File
@@ -37,6 +37,9 @@
#include "gui/colorlcd/LvglWrapper.h"
#endif
#if !defined(SIMU)
#include <malloc.h>
#endif
RadioData g_eeGeneral;
ModelData g_model;
@@ -1926,3 +1929,17 @@ uint32_t pwrCheck()
}
#endif // defined(PWR_BUTTON_PRESS)
#endif // !defined(SIMU)
uint32_t availableMemory()
{
#if defined(SIMU)
return 1000;
#else
extern unsigned char *heap;
extern int _heap_end;
struct mallinfo info = mallinfo();
return ((uint32_t)((unsigned char *)&_heap_end - heap)) + info.fordblks;
#endif
}
+1 -8
View File
@@ -469,14 +469,7 @@ extern uint8_t mixerCurrentFlightMode;
extern uint8_t lastFlightMode;
extern uint8_t flightModeTransitionLast;
#if defined(SIMU)
inline int availableMemory() { return 1000; }
#else
extern unsigned char *heap;
extern int _end;
extern int _heap_end;
#define availableMemory() ((unsigned int)((unsigned char *)&_heap_end - heap))
#endif
extern uint32_t availableMemory();
void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms);