Skip to content

Commit 8ca3c3c

Browse files
Move debug constant strings to PROGMEM
UMM debugging strings are normally placed in RODATA, which uses up scarse memory. Move them to PROGMEM and use macros to replace printf with a version that can handle ROM strings.
1 parent a01638f commit 8ca3c3c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cores/esp8266/umm_malloc/umm_malloc.c

+4
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@
493493

494494
#include <stdio.h>
495495
#include <string.h>
496+
#include <pgmspace.h>
496497

497498
#include "umm_malloc.h"
498499

@@ -512,6 +513,9 @@
512513
# define DBG_LOG_LEVEL DBG_LOG_LEVEL
513514
#endif
514515

516+
// Macro to place constant strings into PROGMEM and print them properly
517+
#define printf(fmt, ...) do { static const char fstr[] PROGMEM = fmt; char rstr[sizeof(fmt)]; for (size_t i=0; i<sizeof(rstr); i++) rstr[i] = fstr[i]; printf(rstr, ##__VA_ARGS__); } while (0)
518+
515519
/* -- dbglog {{{ */
516520

517521
/* ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)