Skip to content

Commit b238824

Browse files
committed
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.
1 parent c4de2fd commit b238824

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

supervisor/shared/memory.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,32 @@
3232
#include "py/gc.h"
3333
#include "supervisor/shared/display.h"
3434

35-
#define CIRCUITPY_SUPERVISOR_ALLOC_COUNT (12)
35+
enum {
36+
CIRCUITPY_SUPERVISOR_ALLOC_COUNT =
37+
// stack + heap
38+
2
39+
#ifdef EXTERNAL_FLASH_DEVICES
40+
+ 1
41+
#endif
42+
#if CIRCUITPY_USB_MIDI
43+
+ 1
44+
#endif
45+
#if CIRCUITPY_DISPLAYIO
46+
#if CIRCUITPY_TERMINALIO
47+
+ 1
48+
#endif
49+
+ CIRCUITPY_DISPLAY_LIMIT * (
50+
// Maximum needs of one display: max(4 if RGBMATRIX, 1 if SHARPDISPLAY, 0)
51+
#if CIRCUITPY_RGBMATRIX
52+
4
53+
#elif CIRCUITPY_SHARPDISPLAY
54+
1
55+
#else
56+
0
57+
#endif
58+
)
59+
#endif
60+
};
3661

3762
// The lowest two bits of a valid length are always zero, so we can use them to mark an allocation
3863
// as a hole (freed by the client but not yet reclaimed into the free middle) and as movable.

0 commit comments

Comments
 (0)