summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorChristian Walther <cwalther@gmx.ch>2020-10-28 21:50:28 +0100
committerChristian Walther <cwalther@gmx.ch>2020-11-28 17:54:34 +0100
commit993a581f5e8c039b562bbacdf17615162d8a85f6 (patch)
tree9ad7d42c3654fb3d901255d1c84ae46c2824ccd9 /supervisor
parent7ca36d45a4ffe40c70814d62cb970007b7f40fee (diff)
Make CIRCUITPY_SUPERVISOR_ALLOC_COUNT dependent on enabled features.
Avoids wasted memory and makes it easier to keep track of who needs how much for future additions.
Diffstat (limited to 'supervisor')
-rwxr-xr-xsupervisor/shared/memory.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c
index 2be3b42d6..1760b9bd6 100755
--- a/supervisor/shared/memory.c
+++ b/supervisor/shared/memory.c
@@ -32,7 +32,32 @@
#include "py/gc.h"
#include "supervisor/shared/display.h"
-#define CIRCUITPY_SUPERVISOR_ALLOC_COUNT (12)
+enum {
+ CIRCUITPY_SUPERVISOR_ALLOC_COUNT =
+ // stack + heap
+ 2
+#ifdef EXTERNAL_FLASH_DEVICES
+ + 1
+#endif
+#if CIRCUITPY_USB_MIDI
+ + 1
+#endif
+#if CIRCUITPY_DISPLAYIO
+ #if CIRCUITPY_TERMINALIO
+ + 1
+ #endif
+ + CIRCUITPY_DISPLAY_LIMIT * (
+ // Maximum needs of one display: max(4 if RGBMATRIX, 1 if SHARPDISPLAY, 0)
+ #if CIRCUITPY_RGBMATRIX
+ 4
+ #elif CIRCUITPY_SHARPDISPLAY
+ 1
+ #else
+ 0
+ #endif
+ )
+#endif
+};
// The lowest two bits of a valid length are always zero, so we can use them to mark an allocation
// as a hole (freed by the client but not yet reclaimed into the free middle) and as movable.